Let us create a simple example solution that demonstrates how to use devmate. For a more detailed example that actually shows the strengths of Equivalence Partitioning please refer to Chapter 3. We start by creating a .Net Core library project:

Let’s call the solution and the new library project “HelloWorld”
Then we add a unit tests project to the solution:

It is important that you select from either “NUnit Test Project”, “xUnit Test Project” or “MSTest Test Project” since devmate currently supports NUnit3, xUnit, and MSTest unit-testing frameworks. After adding the test-project your solution tree should look like this:

Now let us add a static method string Greet(string whom)
to our library project:
namespace HelloWorld
{
public static class Example
{
public static string Greet(string whom)
{
return $"Hello {whom}";
}
}
}
To create a test model for this method just right-click inside the method and select “Test with devmate” from the context menu:

A file dialog will ask you where to store the new test-model. Store it somewhere in your test project:

Now the Equivalence Class Editor opens:

Let us add a representative to the equivalence class “valid” and set its value to “World”:


Now we are ready to generate test cases: Just click on “Generate Test Cases”. A single test with input factor “whom” set to “World” is created. Next set the expected value to “Hello World”. Your test model should look like this:

Finally you are set to generate unit tests. Click on “Generate NUnit Test Code” and store the test in your test-project:

That’s it. You just created your first unit test using devmate:
/*
* DO NOT MODIFY THIS COMMENT
* Generated by devmate
* Test model: 02f3de8a-bcd7-4ea3-81c1-6069425f6944
*/
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace HelloWorldTests
{
public class GreetTestCase
{
#region Test methods
[Test]
[TestCaseSource(nameof(ExpectedReturnValueTests))]
public void GreetTest(ExpectedValueTestData<string> data)
{
var actual = HelloWorld.Example.Greet(data.Params.whom);
Assert.AreEqual(data.ExpectedValue, actual);
}
#endregion
#region Data
private static IEnumerable<TestCaseData> ExpectedReturnValueTests()
{
yield return new TestCaseData(
new ExpectedValueTestData<string>
{
Params = new Parameters
{
whom = "World",
},
ExpectedValue = string.Empty,
}).SetName(@"p1");
}
#endregion
#region Types
public struct ExpectedValueTestData<TExpected>
{
public Parameters Params;
public TExpected ExpectedValue;
}
public struct Parameters
{
public string whom;
}
#endregion
}
}
/*
WARNING: Modification of this comment will make it impossible to merge user-defined changes
BEGIN_CODEGEN_DATA
H4sIAAAAAAAAAIVSXW/aQBB8NhL/YUVfTBSckJA0LSlqBE7CAxAVt1VV9eHwLYnVs8+5O0NQxX/vnj8Aq00rWdbt3sz
OztgnR83GEYxmMJ0FMJmNxrffILgfz2E4m0z8aWBv7zBBxQxyWGyA4yqms+0HqA3EkqN4D6dny3OOV6yzCPnbTg/Zee
eqG3Y7l6eX73pnF0t694hz0mw0G5mOkkeYb7TBuF8vvaEUAkMTyUR7uW4U7iDTz0lkvFvFYlxL9bNvZyVU6JSFCPcoh
PwqleB2L91s/Go2nDRbiCiEUDCt4U4hGns5ZJoMOAR4o/CRtEoraJ4kJ6bjfLeNH7uTJcxlpkJ0raBcuv5LSmsi/4Qm
U8kXJjLMZdvtnFXqrmTE97I70g4+YoZda6PI3QA4FW1Ltos7zoopYKHJmIAPB+Y8/4XFqUAvH+takvfAKBPtrZ9k3O7
n5ButURnvRqH/TBMKWE3+uBxeELYUBSa8SMPmWgVjN8wNqWhFnx20YYaMjf0ki+mnWAi8rgKy0AG8Fox7YG0ToeCgcg
QkuIbDEW4OcWz7n3kVsGKg4xQRUFKWlxdoUOnytkI5NiICtfIoW8dle1sdaoKEK6Q8P07NpsRs294czZTmux9babf1n
/yCTYr64I+giVloXnEWVO3BPquSt7dUHHX/8HZHrA+uVvtTv55QTanwDDapv1mzNT2/AfpH6/84BAAA
END_CODEGEN_DATA
*/
The full source code of this example is available on Github.