Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit 1a7068c

Browse files
committed
[TouchRunner] Only update the UI for a single test after the test has finished running. (#72)
Only update the UI for a single test after we're notified that the test has finished running. This is a step towards making async tests work properly, where we can't assume that the test has finished after calling Run. Also we only want to show more details for a test if we ran that test as a result of tapping on it.
1 parent ba93ddf commit 1a7068c

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

NUnitLite/TouchRunner/TestCaseElement.cs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
namespace MonoTouch.NUnit.UI {
3737

3838
class TestCaseElement : TestElement {
39+
bool tapped;
3940

4041
public TestCaseElement (TestMethod testCase, TouchRunner runner)
4142
: base (testCase, runner)
@@ -59,21 +60,7 @@ public TestCaseElement (TestMethod testCase, TouchRunner runner)
5960
#endif
6061

6162
Runner.CloseWriter ();
62-
// display more details on (any) failure (but not when ignored)
63-
if ((TestCase.RunState == RunState.Runnable) && !Result.IsSuccess ()) {
64-
var root = new RootElement ("Results") {
65-
new Section () {
66-
new TestResultElement (Result)
67-
}
68-
};
69-
var dvc = new DialogViewController (root, true) { Autorotate = true };
70-
runner.NavigationController.PushViewController (dvc, true);
71-
}
72-
// we still need to update our current element
73-
if (GetContainerTableView () != null) {
74-
var root = GetImmediateRootElement ();
75-
root.Reload (this, UITableViewRowAnimation.Fade);
76-
}
63+
tapped = true;
7764
};
7865
}
7966

@@ -83,7 +70,7 @@ public TestMethod TestCase {
8370

8471
public void Run ()
8572
{
86-
Update (Runner.Run (TestCase));
73+
Runner.Run (TestCase);
8774
}
8875

8976
public override void Update ()
@@ -105,6 +92,25 @@ public override void Update ()
10592
// Assert.Ignore falls into this
10693
Value = Result.GetMessage ();
10794
}
95+
96+
if (tapped) {
97+
// display more details on (any) failure (but not when ignored)
98+
if ((TestCase.RunState == RunState.Runnable) && !Result.IsSuccess ()) {
99+
var root = new RootElement ("Results") {
100+
new Section () {
101+
new TestResultElement (Result)
102+
}
103+
};
104+
var dvc = new DialogViewController (root, true) { Autorotate = true };
105+
Runner.NavigationController.PushViewController (dvc, true);
106+
}
107+
// we still need to update our current element
108+
if (GetContainerTableView () != null) {
109+
var root = GetImmediateRootElement ();
110+
root.Reload (this, UITableViewRowAnimation.Fade);
111+
}
112+
tapped = false;
113+
}
108114
}
109115
}
110116
}

NUnitLite/TouchRunner/TestSuiteElement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public TestSuite Suite {
5555

5656
public void Run ()
5757
{
58-
Result = Runner.Run (Suite);
58+
Runner.Run (Suite);
5959
}
6060

6161
public override void Update ()

NUnitLite/TouchRunner/TouchRunner.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ bool AddSuite (TestSuite ts)
515515
return true;
516516
}
517517

518-
public TestResult Run (Test test)
518+
public void Run (Test test)
519519
{
520520
PassedCount = 0;
521521
IgnoredCount = 0;
@@ -551,7 +551,6 @@ ITestResult find_result (ITestResult tr)
551551
wi.Execute (current);
552552
Result = wi.Result;
553553
#endif
554-
return Result;
555554
}
556555

557556
public ITest LoadedTest {

0 commit comments

Comments
 (0)