Skip to content

Commit 8dda462

Browse files
committed
Fix: Report 0 tests found in case it is not a CatchTest exe.
1 parent ff80094 commit 8dda462

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

TestAdapter/TestDiscoverer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ private static IEnumerable<TestCase> ParseListing( string exeName, IList<string>
127127
// The first line should be fixed.
128128
if( !line.MoveNext() || line.Current != "All available test cases:" )
129129
{
130-
throw new Exception( "Unexpected line in catch output: " + line.Current );
130+
yield break;
131+
//throw new Exception( "Unexpected line in catch output: " + line.Current );
131132
}
132133

133134
// Split output to groups of lines related to the same test case.

TestAdapterTest/TestTestDiscoverer.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public class TestTestDiscoverer
1919
// Tests that all the tests in the reference project are found.
2020
[TestMethod]
2121
[DeploymentItem( Common.ReferenceExePath )]
22-
public void DiscoversAllTests()
23-
{
22+
public void DiscoversAllTests()
23+
{
2424
// Initialize a mock sink to keep track of the discovered tests.
2525
MockTestCaseDiscoverySink testSink = new MockTestCaseDiscoverySink();
2626

@@ -145,5 +145,26 @@ public void FiltersTestExecutables()
145145
// There should be no tests, as nothing matches the filter.
146146
Assert.AreEqual( testSink.Tests.Count, 0 );
147147
}
148+
149+
// Tests that a non Catch exe returns no test cases.
150+
[TestMethod]
151+
public void DiscoversNoTests()
152+
{
153+
// Initialize a mock sink to keep track of the discovered tests.
154+
MockTestCaseDiscoverySink testSink = new MockTestCaseDiscoverySink();
155+
156+
TestDiscoverer discoverer = new TestDiscoverer();
157+
var cd = System.IO.Directory.GetCurrentDirectory();
158+
// Unfortunately it doesn't get copied with the DeployItemAttribute, no idea why.
159+
System.IO.File.WriteAllText(@"nonecatchexe.cmd", @"@echo Non Catch Output line");
160+
// Returns an unexpected first line.
161+
discoverer.DiscoverTests(new List<String>(){ @"nonecatchexe.cmd" },
162+
new MockDiscoveryContext(),
163+
new MockMessageLogger(),
164+
testSink);
165+
166+
// Zero test cases should be registered.
167+
Assert.AreEqual(0, testSink.Tests.Count);
168+
}
148169
}
149170
}

source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<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">
33
<Metadata>
4-
<Identity Id="CatchTestAdapter.xkBeyer.f56db3ea-257e-4f65-a52c-a6160aa8e329" Version="1.3" Language="en-US" Publisher="xkbeyer" />
4+
<Identity Id="CatchTestAdapter.xkBeyer.f56db3ea-257e-4f65-a52c-a6160aa8e329" Version="1.3.1" Language="en-US" Publisher="xkbeyer" />
55
<DisplayName>CatchTestAdapter</DisplayName>
66
<Description xml:space="preserve">Test Adapter for the Catch C++ unit test framework</Description>
77
<License>LICENSE.txt</License>

0 commit comments

Comments
 (0)