Step 2: Create your first Test

You are here:
Estimated reading time: 1 min

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:

"Test with devmate" entry in context menu

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

"Save As..." dialog in test project

Now the Equivalence Class Editor opens:

devmate interface in HelloWorld example

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

devmate interface showing type list item context menu
devmate interface showing test value in object list

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:

devmate interface after setting a value

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

"Save As..." dialog for generated test model

That’s it. You just created your first unit test using devmate:

* 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
        public void GreetTest(ExpectedValueTestData<string> data)
            var actual = HelloWorld.Example.Greet(data.Params.whom);
            Assert.AreEqual(data.ExpectedValue, actual);
#region Data
        private static IEnumerable<TestCaseData> ExpectedReturnValueTests()
            yield return new TestCaseData(
                new ExpectedValueTestData<string>
                    Params = new Parameters
                        whom = "World",
                    ExpectedValue = string.Empty,
#region Types
        public struct ExpectedValueTestData<TExpected>
            public Parameters Params;
            public TExpected ExpectedValue;
        public struct Parameters
            public string whom;
WARNING: Modification of this comment will make it impossible to merge user-defined changes

The full source code of this example is available on Github.

Was this article helpful?
Dislike 1
Views: 718

Continue reading

Previous: Step 1: Quickstart (IntelliJ)
Next: Step 3: Boilerplates

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our cookie policy.

Privacy Settings saved!
Privacy Settings

When you visit any web site, it may store or retrieve information on your browser, mostly in the form of cookies. Control your personal Cookie Services here.

GetResponse, Google Analytics

We use LinkedIn Insight for marketing purposes. You can disable these cookies.

We use Google Analytics for marketing purposes. You can disable these cookies.
  • __utmz
  • __utma
  • _ga
  • _gat

We use GetResponse for marketing purposes. This service cannot be disabled, otherwise the website functions will be limited.

Decline all Services
Accept all Services
Get Free Access Now to
9 eBooks!
All about Automated Software Testing
Proven experts
Learn to save up to 75% of your test efforts
Get Free Access Now!
Get Access Now! & Save 50%
Personal Trainer FREE Nutrition Custom Workout App
Get Access Now!
eBook Download
Enter your details to get your free ebook!
All about Automated Software Testing
Download Free Ebook
Lorem ipsum dolor sit amet, consectetur adipiscing