Skip to content

Commit ea1dfda

Browse files
committed
Update test runner
1 parent d9bee6e commit ea1dfda

File tree

4 files changed

+121
-92
lines changed

4 files changed

+121
-92
lines changed

Test/IntegrationTest/Test.aspx.designer.cs

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/IntegrationTest/IntegrationTest.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
<None Remove="App_Config\Include\zWeBlog.Test.ContentSearch.Solr.config" />
99
</ItemGroup>
1010
<ItemGroup>
11-
<PackageReference Include="codeflood.nunit.aspnet.testrunner" Version="1.1.0" />
11+
<PackageReference Include="codeflood.nunit.aspnet.testrunner" Version="1.2.0" />
1212
<PackageReference Include="CookComputing.XmlRPCv2" Version="2.5.0" />
1313
<PackageReference Include="Moq" Version="4.2.1507.0118" />
14-
<PackageReference Include="NUnit" Version="2.6.4" />
15-
<PackageReference Include="NUnit.Runners" Version="2.6.4" />
1614
<ProjectReference Include="..\..\src\Sitecore.Modules.WeBlog\Sitecore.Modules.WeBlog.csproj" />
1715
</ItemGroup>
1816
<ItemGroup>

test/IntegrationTest/Test.aspx

Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,75 +6,21 @@
66
<head runat="server">
77
<title>codeflood Test Runner</title>
88
<style type="text/css">
9-
body {
10-
font-family: Tahoma, Arial, Sans-Serif;
11-
font-size: 10pt;
12-
color: #333333;
13-
}
14-
15-
h1 {
16-
font-size: 1.5em;
17-
}
18-
19-
h2 {
20-
font-size: 1.3em;
21-
}
22-
23-
h3 {
24-
font-size: 1.2em;
25-
}
26-
27-
.filters ul {
28-
padding: 0;
29-
}
30-
31-
.filters li {
32-
list-style: none;
33-
}
34-
35-
.pass {
36-
width: 1em;
37-
height: 1em;
38-
background-color: #5eb95e;
39-
}
40-
41-
.fail {
42-
width: 1em;
43-
height: 1em;
44-
background-color: #dd514c;
45-
}
46-
47-
.notRun {
48-
width: 1em;
49-
height: 1em;
50-
background-color: #fad232;
51-
}
52-
53-
.passLabel {
54-
font-size: 1.3em;
55-
font-weight: bold;
56-
color: #5eb95e;
57-
}
58-
59-
.failLabel {
60-
font-size: 1.3em;
61-
font-weight: bold;
62-
color: #dd514c;
63-
}
64-
65-
.hide {
66-
display: none;
67-
}
68-
69-
.show {
70-
display: block;
71-
}
72-
73-
#filterCategory, #filterMethod {
74-
margin-left: 1em;
75-
padding-left: 1em;
76-
border-left: solid 3px #999999;
77-
}
9+
body { font-family: Tahoma, Arial, Sans-Serif; font-size: 10pt; color: #333333; }
10+
h1 { font-size: 1.5em; }
11+
h2 { font-size: 1.3em; }
12+
h3 { font-size: 1.2em; }
13+
.inlineHeading { display: inline-block; margin-right: 0.5em; }
14+
.filters ul { padding: 0; }
15+
.filters li { list-style: none; }
16+
.pass { width: 1em; height: 1em; background-color: #5eb95e; }
17+
.fail { width: 1em; height: 1em; background-color: #dd514c; }
18+
.notRun { width: 1em; height: 1em; background-color: #fad232; }
19+
.passLabel { font-size: 1.3em; font-weight: bold; color: #5eb95e; }
20+
.failLabel { font-size: 1.3em; font-weight: bold; color: #dd514c; }
21+
.hide { display: none; }
22+
.show { display: block; }
23+
#filterCategory, #filterMethod { margin-left: 1em; padding-left: 1em; border-left: solid 3px #999999; }
7824
</style>
7925
<script type="text/javascript">
8026
function checkAll(checked, containerId) {
@@ -133,7 +79,8 @@ function toggle() {
13379
<div class="filters">
13480
<h2>Filters</h2>
13581
<p>If no filters are selected the entire test suite will run.</p>
136-
<h3>Category</h3>
82+
<h3 class="inlineHeading">Category</h3>
83+
<span>(<%= cblCategories.Items.Count %>)</span>
13784
<p>
13885
<a id="hideCategoryFilter" class="hide" href="javascript:void(0)" onclick="toggle('filterCategory', 'hideCategoryFilter', 'showCategoryFilter')">hide</a>
13986
<a id="showCategoryFilter" class="show" href="javascript:void(0)" onclick="toggle('filterCategory', 'showCategoryFilter', 'hideCategoryFilter')">show</a>
@@ -145,7 +92,8 @@ function toggle() {
14592
</p>
14693
<asp:CheckBoxList runat="server" ID="cblCategories" RepeatLayout="UnorderedList" ClientIDMode="Static" />
14794
</div>
148-
<h3>Test Methods</h3>
95+
<h3 class="inlineHeading">Test Methods</h3>
96+
<span>(<%= cblMethods.Items.Count %>)</span>
14997
<p>
15098
<a id="hideMethodFilter" class="hide" href="javascript:void(0)" onclick="toggle('filterMethod', 'hideMethodFilter', 'showMethodFilter')">hide</a>
15199
<a id="showMethodFilter" class="show" href="javascript:void(0)" onclick="toggle('filterMethod', 'showMethodFilter', 'hideMethodFilter')">show</a>

test/IntegrationTest/Test.aspx.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ protected void Page_Load(object sender, EventArgs e)
4343
if (!IsPostBack)
4444
{
4545
var testSuite = new TestSuiteBuilder().Build(_testPackage);
46-
47-
LoadCategories(testSuite);
48-
LoadTestMethodNames(testSuite);
46+
LoadFilters(testSuite);
4947
}
5048

5149
// Select filters from query string
@@ -57,21 +55,17 @@ protected void Page_Load(object sender, EventArgs e)
5755
Run();
5856
}
5957

60-
protected void LoadTestMethodNames(ITest test)
58+
protected void LoadFilters(ITest test)
6159
{
62-
var names = new List<string>();
63-
FindTestMethodNames(test, names);
60+
var methodNames = new List<string>();
61+
var categoryNames = new HashSet<string>();
6462

65-
cblMethods.DataSource = names;
66-
cblMethods.DataBind();
67-
}
63+
InspectTests(test, methodNames, categoryNames);
6864

69-
protected void LoadCategories(ITest test)
70-
{
71-
var categoryManager = new CategoryManager();
72-
categoryManager.AddAllCategories(test);
65+
cblMethods.DataSource = methodNames;
66+
cblMethods.DataBind();
7367

74-
cblCategories.DataSource = (from string cat in categoryManager.Categories select cat).OrderBy(x => x);
68+
cblCategories.DataSource = (from string cat in categoryNames select cat).OrderBy(x => x);
7569
cblCategories.DataBind();
7670
}
7771

@@ -115,18 +109,27 @@ where item.Selected
115109
return new OrFilter(categoryFilter, methodFilter);
116110
}
117111

118-
protected void FindTestMethodNames(ITest test, List<string> list)
112+
protected void InspectTests(ITest test, List<string> methodNames, HashSet<string> categoryNames)
119113
{
120114
foreach (ITest t in test.Tests)
121115
{
122116
if (t is NUnitTestMethod)
123117
{
124-
list.Add(t.TestName.FullName);
118+
methodNames.Add(t.TestName.FullName);
119+
}
120+
121+
if(t.Categories != null)
122+
{
123+
foreach(string category in t.Categories)
124+
{
125+
if (NUnitFramework.IsValidCategoryName(category) && !categoryNames.Contains(category))
126+
categoryNames.Add(category);
127+
}
125128
}
126129

127130
if (t.Tests != null)
128131
{
129-
FindTestMethodNames(t, list);
132+
InspectTests(t, methodNames, categoryNames);
130133
}
131134
}
132135
}
@@ -157,7 +160,9 @@ protected void OutputVisual(TestResult result)
157160
protected void OutputXml(TestResult result)
158161
{
159162
var builder = new StringBuilder();
160-
new XmlResultWriter(new StringWriter(builder)).SaveTestResult(result);
163+
var writer = new StringWriter(builder);
164+
var resultWriter = new XmlResultWriter(writer);
165+
resultWriter.SaveTestResult(result);
161166

162167
Response.ContentType = "text/xml";
163168
Response.Write(builder.ToString());

0 commit comments

Comments
 (0)