Skip to content

Commit

Permalink
Fix: Report 0 tests found in case it is not a CatchTest exe.
Browse files Browse the repository at this point in the history
  • Loading branch information
xkbeyer committed May 27, 2018
1 parent ff80094 commit 8dda462
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion TestAdapter/TestDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ private static IEnumerable<TestCase> ParseListing( string exeName, IList<string>
// The first line should be fixed.
if( !line.MoveNext() || line.Current != "All available test cases:" )
{
throw new Exception( "Unexpected line in catch output: " + line.Current );
yield break;
//throw new Exception( "Unexpected line in catch output: " + line.Current );
}

// Split output to groups of lines related to the same test case.
Expand Down
25 changes: 23 additions & 2 deletions TestAdapterTest/TestTestDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class TestTestDiscoverer
// Tests that all the tests in the reference project are found.
[TestMethod]
[DeploymentItem( Common.ReferenceExePath )]
public void DiscoversAllTests()
{
public void DiscoversAllTests()
{
// Initialize a mock sink to keep track of the discovered tests.
MockTestCaseDiscoverySink testSink = new MockTestCaseDiscoverySink();

Expand Down Expand Up @@ -145,5 +145,26 @@ public void FiltersTestExecutables()
// There should be no tests, as nothing matches the filter.
Assert.AreEqual( testSink.Tests.Count, 0 );
}

// Tests that a non Catch exe returns no test cases.
[TestMethod]
public void DiscoversNoTests()
{
// Initialize a mock sink to keep track of the discovered tests.
MockTestCaseDiscoverySink testSink = new MockTestCaseDiscoverySink();

TestDiscoverer discoverer = new TestDiscoverer();
var cd = System.IO.Directory.GetCurrentDirectory();
// Unfortunately it doesn't get copied with the DeployItemAttribute, no idea why.
System.IO.File.WriteAllText(@"nonecatchexe.cmd", @"@echo Non Catch Output line");
// Returns an unexpected first line.
discoverer.DiscoverTests(new List<String>(){ @"nonecatchexe.cmd" },
new MockDiscoveryContext(),
new MockMessageLogger(),
testSink);

// Zero test cases should be registered.
Assert.AreEqual(0, testSink.Tests.Count);
}
}
}
2 changes: 1 addition & 1 deletion source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="CatchTestAdapter.xkBeyer.f56db3ea-257e-4f65-a52c-a6160aa8e329" Version="1.3" Language="en-US" Publisher="xkbeyer" />
<Identity Id="CatchTestAdapter.xkBeyer.f56db3ea-257e-4f65-a52c-a6160aa8e329" Version="1.3.1" Language="en-US" Publisher="xkbeyer" />
<DisplayName>CatchTestAdapter</DisplayName>
<Description xml:space="preserve">Test Adapter for the Catch C++ unit test framework</Description>
<License>LICENSE.txt</License>
Expand Down

0 comments on commit 8dda462

Please sign in to comment.