Skip to content

Commit

Permalink
Outcome filtering: remove 'All' outcome button
Browse files Browse the repository at this point in the history
  • Loading branch information
rowo360 committed Dec 13, 2024
1 parent 46c7f0c commit 16e8b26
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 98 deletions.

This file was deleted.

Binary file not shown.
26 changes: 12 additions & 14 deletions src/TestCentric/testcentric.gui/Views/TestTreeView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/TestCentric/testcentric.gui/Views/TestTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public TestTreeView()
CollapseToFixturesCommand = new CommandMenuElement(collapseToFixturesMenuItem);
TestPropertiesCommand = new CommandMenuElement(testPropertiesMenuItem);
ViewAsXmlCommand = new CommandMenuElement(viewAsXmlMenuItem);
OutcomeFilter = new MultiCheckedToolStripButtonGroupWithDefaultButton(new[] { filterOutcomeAllButton, filterOutcomePassedButton, filterOutcomeFailedButton, filterOutcomeNotRunButton });
OutcomeFilter = new MultiCheckedToolStripButtonGroup(new[] { filterOutcomePassedButton, filterOutcomeFailedButton, filterOutcomeWarningButton, filterOutcomeNotRunButton });
TreeView = treeView;

LoadOutcomeFilterImages();
Expand Down Expand Up @@ -234,6 +234,7 @@ private void LoadOutcomeFilterImages()

filterOutcomeFailedButton.Image = LoadAlternateImage("Failure", imageDir);
filterOutcomePassedButton.Image = LoadAlternateImage("Success", imageDir);
filterOutcomeWarningButton.Image = LoadAlternateImage("Ignored", imageDir);
filterOutcomeNotRunButton.Image = LoadAlternateImage("Skipped", imageDir);
}

Expand Down
6 changes: 1 addition & 5 deletions src/TestCentric/testcentric.gui/Views/TestTreeView.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAB+
DQAAAk1TRnQBSQFMAgEBBQEAAVABBQFUAQUBEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo
DQAAAk1TRnQBSQFMAgEBBQEAAVABBQFYAQUBEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down Expand Up @@ -189,8 +189,4 @@
AeABAQIAAfABDwHwAQ8B8AEBAgAB+AEfAfgBHwH4ARsCAAb/GAAL
</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="FilterAllOutcomes.Image" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\FilterAllOutcomes.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
12 changes: 6 additions & 6 deletions src/TestModel/model/Filter/OutcomeFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class OutcomeFilter : ITestFilter
public const string AllOutcome = "All";
public const string NotRunOutcome = "Not Run";

private List<string> _condition = new List<string>() { AllOutcome };
private List<string> _condition = new List<string>();

internal OutcomeFilter(ITestModel model)
{
Expand All @@ -36,7 +36,7 @@ public IEnumerable<string> Condition
public bool IsMatching(TestNode testNode)
{
// All kind of outcomes should be displayed (no outcome filtering)
if (_condition.Contains(AllOutcome))
if (_condition.Contains(AllOutcome) || !_condition.Any())
return true;

string outcome = NotRunOutcome;
Expand All @@ -48,11 +48,11 @@ public bool IsMatching(TestNode testNode)
{
case TestStatus.Failed:
case TestStatus.Passed:
case TestStatus.Inconclusive:
outcome = result.Outcome.Status.ToString();
break;
case TestStatus.Inconclusive:
case TestStatus.Skipped:
outcome = result.Outcome.Label == "Ignored" ? "Ignored" : "Skipped";
outcome = "Warning";
break;
}
}
Expand All @@ -62,12 +62,12 @@ public bool IsMatching(TestNode testNode)

public void Reset()
{
_condition = new List<string>() { AllOutcome };
_condition = new List<string>();
}

public void Init()
{
_condition = new List<string>() { AllOutcome };
_condition = new List<string>();
}
}
}
16 changes: 10 additions & 6 deletions src/TestModel/tests/TestCentricTestFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,23 @@ public void ClearFilter_AllFiltersAreReset()
Assert.That(allCategories, Contains.Item(CategoryFilter.NoCategory));

var outcomeFilter = testFilter.OutcomeFilter;
Assert.That(outcomeFilter.Count, Is.EqualTo(1));
Assert.That(outcomeFilter, Contains.Item(OutcomeFilter.AllOutcome));
Assert.That(outcomeFilter.Count, Is.EqualTo(0));

Assert.That(testFilter.TextFilter, Is.Empty);
}

private static object[] FilterByOutcomeTestCases =
{
{
new object[] { new List<string>() { "Passed" }, new List<string>() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1022" } },
new object[] { new List<string>() { "Failed" }, new List<string>() { "3-1000", "3-1001", "3-1020", "3-1021" } },
new object[] { new List<string>() { OutcomeFilter.NotRunOutcome }, new List<string>() { "3-1000", "3-1001", "3-1030", "3-1031", "3-1032" } },
new object[] { new List<string>() { "Passed", OutcomeFilter.NotRunOutcome }, new List<string>() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1022", "3-1030", "3-1031", "3-1032" } },
new object[] { new List<string>() { "Passed", "Failed" }, new List<string>() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1022", "3-1020", "3-1021" } },
new object[] { new List<string>() { OutcomeFilter.NotRunOutcome, "Failed" }, new List<string>() { "3-1000", "3-1001", "3-1030", "3-1031", "3-1032", "3-1020", "3-1021" } },
new object[] { new List<string>() { OutcomeFilter.AllOutcome }, new List<string>() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1021", "3-1022", "3-1030", "3-1031", "3-1032" } },
};
new object[] { new List<string>() { "Warning"}, new List<string>() { "3-1000", "3-1001", "3-1040", "3-1042"} },
new object[] { new List<string>() { OutcomeFilter.AllOutcome }, new List<string>() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1021", "3-1022", "3-1030", "3-1031", "3-1032", "3-1040", "3-1041", "3-1042" } },
new object[] { new List<string>(), new List<string>() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1021", "3-1022", "3-1030", "3-1031", "3-1032", "3-1040", "3-1041", "3-1042" } },
};

[Test]
[TestCaseSource(nameof(FilterByOutcomeTestCases))]
Expand All @@ -165,7 +166,10 @@ public void FilterByOutcome_TestNodesAreVisible(IList<string> outcomeFilter, ILi
CreateTestcaseXml("3-1022", "TestB", "Passed")) +
CreateTestFixtureXml("3-1030", "Fixture_3", "",
CreateTestcaseXml("3-1031", "TestA", ""),
CreateTestcaseXml("3-1032", "TestB", "")))));
CreateTestcaseXml("3-1032", "TestB", "")) +
CreateTestFixtureXml("3-1040", "Fixture_4", "",
CreateTestcaseXml("3-1041", "TestA", ""),
CreateTestcaseXml("3-1042", "TestB", "Skipped")))));
_model.LoadedTests.Returns(testNode);

// Act
Expand Down

0 comments on commit 16e8b26

Please sign in to comment.