Skip to content
Matthew Kelly edited this page Feb 26, 2017 · 3 revisions

TestDriven.NET

Edison can be used with TestDriven.NET. To do this, instead of installing the Edison.Framework from NuGet install the Edison.TestDriven package from NuGet. Then you'll need to manually add a reference to the Edison.Framework.dll within the Edison.TestDriven\tools directory of the project's NuGet packages directory. Now you can Right-click > Run Test(s) with TestDriven.NET on tests using Edison.

Look and Feel

Using Edison is very similar to other test frameworks. You have a [Test] Attribute with varying other Attributes to create your tests. An example would be:

[TestFixture]
public class TestClass
{
	[Setup]
	public void Setup()
	{
		//stuff
	}

	[Teardown]
	public void Teardown(TestResult result)
	{
		//stuff
	}

	[Test]
	[Category("Name")]
	[TestCase(1)]
	[TestCase(2)]
	public void Test(int value)
	{
		AssertFactory.Instance.AreEqual(2, value, "Argh no it's an error!!!1");
	}
}

Here you can see that this is similar to other test frameworks. Edison has been designed this way to make it easier for people to transition over.

In the example above we have:

  • A TestFixture which contains multiple Tests to be run
  • A Setup method which is run before each Test
  • A Teardown method which is run after each Test. This can optionally take a TestResult object.
  • And one Test method, which has a Category of "Name", and two possible TestCases to run the Test with as 1 and 2.

Furthermore, there's the Asserts class. In Edison the main Assert class implements the IAssert interface. To use the Assert class you can either create an instance of it for each Test, or you can use the AssertFactory class. The AssertFactory class contains a lazy Instance property which returns the IAssert class being used for the test assembly. This means you can create your own CustomAssert class that inherits IAssert and do AssertFactory.Instance = new CustomAssert() and any calls to AssertFactory.Instance will return your CustomAssert. This makes it far simpler to have your own assert logic in your test framework. If you don't set the AssertFactory.Instance then this is default to be the inbuilt Assert logic.

We'll go over most of these in far greater detail within the sub-pages.

Clone this wiki locally