Freigeben über


EMTF 2.0 Beta released

It's been a couple of months since I first blogged about EMTF. Since then I've been busy refining and extending the framework and I'm happy to announce that the beta release of version 2.0 is finally done! Special thanks to Josh Poley since a lot of the new functionality is based on his feedback. So, allow me to give you a tour of what's new in Reality EMTF 2.0:

Pre- and post-test actions

The PreTestActionAttribute and PostTestActionAttribute attributes have been added to allow defining methods that are executed before/after each test method in a test class. This is most commonly used for shared setup and teardown of the environment required by a set of tests.

[TestClass]

public class Tests

{

    // Will be executed before every test in the Tests class

    [PreTestAction]

    public void PreTestAction() { }

    // Will be executed after every passed test in the Tests class

    [PostTestAction]

    public void PostTestAction() { }

}

Aborting tests, custom logging and the TestContext

Test methods as well as pre- and post-test actions can take one parameter of the type TestContext. If they do an instance will be automatically provided by the runtime. The test context allows aborting a test from within the test implementation e.g. in case test initialization fails. It also allows adding arbitrary information to the test log.

[Test]

public void Test(TestContext context)

{

    context.LogLine("Initialization failed");

    context.AbortTest();

}

Test groups

The TestGroupsAttribute attribute allows tagging test methods as belonging to one or multiple test groups. At the same time, there are new TestExecutor.Execute() overloads which limit test execution to tests belonging to the specified group(s).

[TestClass]

public class Tests

{

    [Test]

    [TestGroups("BVT")]

    public void Bvt() { }

    [Test]

    [TestGroups("BVT", "STRESS")]

    public void StressBvt() { }

    [Test]

    [TestGroups("STRESS")]

    public void Stress() { }

}

class Program

{

    static void Main(string[] args)

    {

        // Will only run Bvt() and StressBvt()

        new TestExecutor().Execute(new String[] { "BVT" });

    }

}

Concurrent test runs

EMTF now supports concurrent test runs in order to take advantage of multi-core CPUs. Concurrent test runs will execute tests on multiple threads instead of just one. The number of threads used is equal to the number of logical processors on the local machine.

TestExecutor executor = new TestExecutor();

executor.ConcurrentTestRuns = true;

executor.Execute();

Plain text logging to a stream

The logging library has also been extended and now includes the StreamLogger which writes a plain text log to a stream.

TestExecutor executor = new TestExecutor();

using (Stream stream = new FileStream("testrun.log", FileMode.Create))

{

    StreamLogger logger = new StreamLogger(executor, stream);

    executor.Execute();

    logger.Close();

}

 

This posting is provided "AS IS" with no warranties, and confers no rights.

Comments