Anders Forsgren
Anders Forsgren

Reputation: 11111

Print MSTest summary after command line exeution

When running a large set of tests using MsTest from the command line, I can see each test executing and its outcome logged in the window like so:

Passed         Some.NameSpace.Test1
Passed         Some.NameSpace.Test2

And so on for thousands of tests. Once completed, MsTest will spit out a summary like this

Summary
---------
Test run failed 
    Passed  2000
    Failed     1
    ------------
    Total   2001

At this point I either have to start scrolling backwards in the window trying to find the needle in a haystack that represents my single failing test, or I can open the huge xml file that represents the result, and text-search for some keyword indicating a failed test.

Isn't there an easier way? Can I have MsTest report progress without dumping Passed test names to the console (still logging failed ones), or can I have a summary of just Failed tests at the end?

I think its obvious what any command line user wants to do: follow progress AND know the outcome at the end, without having to read xml or browse the cmd window history.

Upvotes: 1

Views: 822

Answers (2)

Anders Forsgren
Anders Forsgren

Reputation: 11111

Answering my own question: A simple wrapper/parser script that calls MsTest.exe and parses/summarizes the output, either the stdout or the trx, is the only solution it seems.

Upvotes: 2

chaliasos
chaliasos

Reputation: 9793

You could use the TestContext.CurrentTestOutcome at the end of each test to determine if the test was failed and then log all failed tests to a different file.

[TestCleanup]
public void CleanUp()
{
    if (TestContext.CurrentTestOutcome.ToString().Equals("Failed"))
    {                
        TestContext.WriteLine("{0}.{1} ==> {2}", TestContext.FullyQualifiedTestClassName, 
            TestContext.TestName, TestContext.CurrentTestOutcome.ToString());

        //Log the result to a file.
    }
}

I don't know if this could help you.

Upvotes: 0

Related Questions