Skip to content

Commit 4b6b259

Browse files
authored
Fix ms test exception parsing (#897)
1 parent 00dd59a commit 4b6b259

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
Type: ParseException,
3-
Message: Expected content to contain `Directory:` or `VerifyException : Directory:` at the start. Ensure the current stable of Verify is being used.
3+
Message: Expected content to contain `Directory:`, or `VerifyException : Directory:`, or `VerifyException: Directory:` at the start. Ensure the current stable of Verify is being used.
44
}

src/Verify.ExceptionParsing.Tests/ExceptionParsingTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public Task MsTest()
120120
{
121121
var exceptionMessage = $"""
122122
Test method TheTests.XAMLCombinerTests.TestOutput threw exception:
123-
VerifyException : Directory: {Environment.CurrentDirectory}
123+
VerifyException: Directory: {Environment.CurrentDirectory}
124124
NotEqual:
125125
- Received: XAMLCombinerTests.TestOutput.received.xaml
126126
Verified: XAMLCombinerTests.TestOutput.verified.xaml

src/Verify.ExceptionParsing/Parser.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ void ThrowIfEmpty(string directory)
119119
return directory;
120120
}
121121

122+
// MsTest
123+
if (firstLine.StartsWith("VerifyException: Directory: "))
124+
{
125+
var directory = firstLine[28..];
126+
127+
ThrowIfEmpty(directory);
128+
129+
return directory;
130+
}
131+
122132
if (firstLine.StartsWith("Directory: "))
123133
{
124134
var directory = firstLine[11..];
@@ -128,7 +138,7 @@ void ThrowIfEmpty(string directory)
128138
return directory;
129139
}
130140

131-
throw new ParseException("Expected content to contain `Directory:` or `VerifyException : Directory:` at the start.");
141+
throw new ParseException("Expected content to contain `Directory:`, or `VerifyException : Directory:`, or `VerifyException: Directory:` at the start.");
132142
}
133143

134144
static string TrimStart(string next, string prefix)

0 commit comments

Comments
 (0)