Skip to content

Commit

Permalink
Added Retry knowledge for TeamCityListener
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryLCoxJr committed Aug 14, 2012
1 parent d33f58d commit 0044e21
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/StoryTeller.TestRunner/TestRunner.cs
Expand Up @@ -86,6 +86,11 @@ public void Exception(string exceptionString)
public bool CanContinue(Counts counts)
{
return true;
}
}

public void FinishTestRetries(Test test)
{

}
}
}
5 changes: 5 additions & 0 deletions src/StoryTeller.Testing/Engine/TestContextTester.cs
Expand Up @@ -569,6 +569,11 @@ public bool CanContinue(Counts counts)
return StepsRun < StepsAllowed;
}

public void FinishTestRetries(Test test)
{

}

#endregion
}

Expand Down
5 changes: 5 additions & 0 deletions src/StoryTeller/Engine/ConsoleListener.cs
Expand Up @@ -64,6 +64,11 @@ public bool CanContinue(Counts counts)
return true;
}

public virtual void FinishTestRetries(Test test)
{
write("Final test status after retries: {0}", test.LastResult.Counts.WasSuccessful() ? "Successful" : "Failure");
}

public override object InitializeLifetimeService()
{
return null;
Expand Down
1 change: 1 addition & 0 deletions src/StoryTeller/Engine/ITestObserver.cs
Expand Up @@ -15,5 +15,6 @@ public interface ITestObserver
void Exception(string exceptionString);

bool CanContinue(Counts counts);
void FinishTestRetries(Test test);
}
}
18 changes: 18 additions & 0 deletions src/StoryTeller/Engine/TeamCityTestListener.cs
Expand Up @@ -16,6 +16,24 @@ public override void StartTest(Test test, Counts counts)
}

public override void FinishTest(Test test)
{
if (!test.LastResult.Counts.WasSuccessful())
{
if (test.Lifecycle == Lifecycle.Regression)
{
Console.WriteLine("##teamcity[testIgnored name='{0}' details='{1}']", test.Name.Escape(),
getFailureDetails(test).Escape());
}
else
{
Console.WriteLine("##teamcity[testIgnored name='{0}' message='{1}']", test.Name.Escape(),
"Acceptance test failed: " + getFailureDetails(test).Escape());
}
}
Console.WriteLine("##teamcity[testFinished name='{0}']", test.Name.Escape());
}

public override void FinishTestRetries(Test test)
{
if (!test.LastResult.Counts.WasSuccessful())
{
Expand Down
2 changes: 2 additions & 0 deletions src/StoryTeller/Execution/ITestRunnerDomain.cs
@@ -1,4 +1,5 @@
using System;
using StoryTeller.Domain;
using StoryTeller.Engine;
using StoryTeller.Model;
using StoryTeller.Workspace;
Expand All @@ -15,6 +16,7 @@ public interface ITestRunnerDomain : IDisposable
TestResult RunTest(TestExecutionRequest request);
void AbortCurrentTest();
bool IsExecuting();
void MarkTestFinalStatus(Test test);

FixtureLibrary Library { get; }
void UseTeamCityListener();
Expand Down
6 changes: 6 additions & 0 deletions src/StoryTeller/Execution/InProcessTestEngine.cs
@@ -1,4 +1,5 @@
using System;
using StoryTeller.Domain;
using StoryTeller.Engine;
using StoryTeller.Model;
using StoryTeller.Workspace;
Expand Down Expand Up @@ -47,6 +48,11 @@ public bool IsExecuting()
throw new NotImplementedException();
}

public void MarkTestFinalStatus(Test test)
{
throw new NotImplementedException();
}

public FixtureLibrary Library
{
get { throw new NotImplementedException(); } }
Expand Down
3 changes: 2 additions & 1 deletion src/StoryTeller/Execution/ProjectTestRunner.cs
Expand Up @@ -149,7 +149,8 @@ public void RunAll(Func<Hierarchy, IEnumerable<Test>> selectionFilter, Action<Te
}
_engine.RunTest(t);
numberOfRetries++;
}
}
_engine.TestRetriesFinished(t);
callback(t);
});
}
Expand Down
6 changes: 5 additions & 1 deletion src/StoryTeller/Execution/TestEngine.cs
Expand Up @@ -119,7 +119,6 @@ public TestStopConditions StopConditions
public void AbortCurrentTest()
{
_domain.AbortCurrentTest();


}

Expand Down Expand Up @@ -164,5 +163,10 @@ public void UseTeamCityListener()
{
_domain.UseTeamCityListener();
}

public void TestRetriesFinished(Test test)
{
_domain.MarkTestFinalStatus(test);
}
}
}
26 changes: 19 additions & 7 deletions src/StoryTeller/Execution/TestRunnerDomain.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
using StoryTeller.Domain;
using StoryTeller.Engine;
using StoryTeller.Model;
using StoryTeller.Workspace;
Expand Down Expand Up @@ -32,7 +33,7 @@ public void LoadProject(IProject project)
_publisher.Publish<BinaryRecycleStarted>();
_proxy = BuildProxy(project);

_library = _proxy.StartSystem(new FixtureAssembly(project), (MarshalByRefObject) _publisher);
_library = _proxy.StartSystem(new FixtureAssembly(project), (MarshalByRefObject)_publisher);
_publisher.Publish(new BinaryRecycleFinished(_library));
}
catch (FileNotFoundException ex)
Expand All @@ -44,13 +45,15 @@ public void LoadProject(IProject project)
"\nYou will not be able to execute tests until the StoryTeller.dll file is copied to " +
project.GetBinaryFolder();

_publisher.Publish(new BinaryRecycleFailure{
_publisher.Publish(new BinaryRecycleFailure
{
ErrorMessage = message
});
}
else
{
_publisher.Publish(new BinaryRecycleFailure{
_publisher.Publish(new BinaryRecycleFailure
{
ErrorMessage = ex.ToString()
});
}
Expand All @@ -60,7 +63,8 @@ public void LoadProject(IProject project)
catch (Exception ex)
{
Teardown();
_publisher.Publish(new BinaryRecycleFailure{
_publisher.Publish(new BinaryRecycleFailure
{
ErrorMessage = ex.ToString()
});
}
Expand Down Expand Up @@ -106,7 +110,8 @@ public TestResult RunTest(TestExecutionRequest request)
public void AbortCurrentTest()
{
_proxy.AbortCurrentTest();
_publisher.Publish(new TestStatusMessage{
_publisher.Publish(new TestStatusMessage
{
IsRunning = false,
WasCancelled = true
});
Expand All @@ -117,6 +122,12 @@ public bool IsExecuting()
return _proxy.IsExecuting();
}

public void MarkTestFinalStatus(Test test)
{
if (_listener != null)
_listener.FinishTestRetries(test);
}

public FixtureLibrary Library
{
get { return _library; }
Expand Down Expand Up @@ -155,7 +166,8 @@ public void Dispose()

public virtual TestRunnerProxy BuildProxy(IProject project)
{
var setup = new AppDomainSetup{
var setup = new AppDomainSetup
{
ApplicationName = "StoryTeller-Testing-" + Guid.NewGuid(),
ConfigurationFile = project.ConfigurationFileName,
ShadowCopyFiles = "true",
Expand All @@ -164,7 +176,7 @@ public virtual TestRunnerProxy BuildProxy(IProject project)

_domain = AppDomain.CreateDomain("StoryTeller-Testing", null, setup);

Type proxyType = typeof (TestRunnerProxy);
Type proxyType = typeof(TestRunnerProxy);
var proxy =
(TestRunnerProxy)
_domain.CreateInstanceAndUnwrap(proxyType.Assembly.FullName, proxyType.FullName);
Expand Down
6 changes: 6 additions & 0 deletions src/StoryTeller/Execution/UserInterfaceTestObserver.cs
Expand Up @@ -119,5 +119,11 @@ public virtual void Publish()
{
_publisher.Publish(GetStatus());
}


public void FinishTestRetries(Test test)
{

}
}
}

0 comments on commit 0044e21

Please sign in to comment.