Skip to content

Commit

Permalink
Merge pull request #866 from nunit/Issue779
Browse files Browse the repository at this point in the history
Issue779
  • Loading branch information
OsirisTerje authored May 31, 2021
2 parents e9b1e8d + 41dabe8 commit 4acde44
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
17 changes: 10 additions & 7 deletions src/NUnitTestAdapter/NUnitEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,18 @@ public void TestFinished(INUnitTestEventTestCase resultNode)
}
}

recorder.RecordEnd(result.TestCaseResult.TestCase, result.TestCaseResult.Outcome);
foreach (var vsResult in result.TestResults)
if (result.TestCaseResult != null)
{
recorder.RecordResult(vsResult);
}
recorder.RecordEnd(result.TestCaseResult.TestCase, result.TestCaseResult.Outcome);
foreach (var vsResult in result.TestResults)
{
recorder.RecordResult(vsResult);
}

if (result.TestCaseResult.Outcome == TestOutcome.Failed && settings.StopOnError)
{
executor.StopRun();
if (result.TestCaseResult.Outcome == TestOutcome.Failed && settings.StopOnError)
{
executor.StopRun();
}
}
}

Expand Down
24 changes: 11 additions & 13 deletions src/NUnitTestAdapter/TestFilterConverter/TestFilterParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public string ParseFilterExpression()

var sb = new StringBuilder("<or>");

foreach (string term in terms)
foreach (var term in terms)
sb.Append(term);

sb.Append("</or>");
Expand All @@ -111,7 +111,7 @@ public string ParseFilterTerm()

var sb = new StringBuilder("<and>");

foreach (string element in elements)
foreach (var element in elements)
sb.Append(element);

sb.Append("</and>");
Expand All @@ -128,12 +128,12 @@ public string ParseFilterCondition()
if (LookingAt(LPAREN, NOT_OP))
return ParseExpressionInParentheses();

Token lhs = Expect(TokenKind.Word);
var lhs = Expect(TokenKind.Word);

if (!LookingAt(REL_OPS))
return EmitFullNameFilter(CONTAINS_OP, lhs.Text);

Token op = Expect(REL_OPS);
var op = Expect(REL_OPS);
Token rhs;

switch (lhs.Text)
Expand All @@ -153,10 +153,8 @@ public string ParseFilterCondition()

default:
// Assume it's a property name
// op = Expect(REL_OPS);
// rhs = Expect(TokenKind.String, TokenKind.Word);
// return EmitPropertyElement(op, lhs, rhs);
throw InvalidTokenError(lhs);
rhs = Expect(TokenKind.String, TokenKind.Word);
return EmitPropertyFilter(op, lhs.Text, rhs.Text);
}
}

Expand Down Expand Up @@ -217,11 +215,11 @@ private static string EscapeRhsValue(Token op, string rhs)

private string ParseExpressionInParentheses()
{
Token op = Expect(LPAREN, NOT_OP);
var op = Expect(LPAREN, NOT_OP);

if (op == NOT_OP) Expect(LPAREN);

string result = ParseFilterExpression();
var result = ParseFilterExpression();

Expect(RPAREN);

Expand All @@ -234,7 +232,7 @@ private string ParseExpressionInParentheses()
// Require a token of one or more kinds
private Token Expect(params TokenKind[] kinds)
{
Token token = NextToken();
var token = NextToken();

if (kinds.Any(kind => token.Kind == kind))
{
Expand All @@ -247,7 +245,7 @@ private Token Expect(params TokenKind[] kinds)
// Require a token from a list of tokens
private Token Expect(params Token[] valid)
{
Token token = NextToken();
var token = NextToken();

if (valid.Any(item => token == item))
{
Expand Down Expand Up @@ -284,7 +282,7 @@ private static string EscapeRegexChars(string input)
{
var sb = new StringBuilder();

foreach (char c in input)
foreach (var c in input)
{
if (REGEX_CHARS.Contains(c))
sb.Append('\\');
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/TestFilterConverter/Tokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public enum TokenKind
Eof,
Word,
FQN,
// String, // Unused
String, // Unused
Symbol
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public void CreateParser()
[TestCase(
"TestCategory=Urgent & !(FullyQualifiedName=My.Tests | TestCategory = high)",
"<and><cat>Urgent</cat><not><or><test>My.Tests</test><cat>high</cat></or></not></and>")]
[TestCase("Bug = 12345", "<prop name='Bug'>12345</prop>")]
public void TestParser(string input, string output)
{
Assert.That(_parser.Parse(input), Is.EqualTo($"<filter>{output}</filter>"));
Expand Down

0 comments on commit 4acde44

Please sign in to comment.