public Result ExecuteInDelegate(KataraiSettings settings, string shadowLocation) { var newPlayerAssemblyPath = ShadowCopyPlayerAssembly(shadowLocation, settings.PlayerPath); var runner = new Runner.Runner(settings.KataPath, newPlayerAssemblyPath, newPlayerAssemblyPath); return(runner.Run()); }
public void RunAllInCaseInOrder() { sut = new Runner.Runner( OnSetupsFinished, OnTestsFinished, OnTearDownsFinished, () => { }, () => { }); sut.AddCase( typeof(RunAllInCaseInOrder)); // Act. sut.Start(); // Assert. new[] { _setupsRunCounter.Count(), _testsRunCounter.Count(), _tearDownsRunCounter.Count() }.Should() .AllBeEquivalentTo(1, because: "Each of Setup, Test and TearDown should only have been run once."); _setupsRunCounter.Max().Should() .BeLessThan(_testsRunCounter.Min(), because: "Setup should be run before Test."); _testsRunCounter.Max().Should() .BeLessThan(_tearDownsRunCounter.Min(), because: "Test should be run before TearDown."); }
public void ProcessAnalysisResult_GivenNewTestWithoutRunningTestsAfterPreviousImplementation_ShouldDisplayMessage() { //---------------Set up test pack------------------- var configuration = new Configuration(); var kataImplementationTypes = configuration.GetKataImplementationTypes(); var runner = new Runner.Runner("", "", ""); var notifier = Substitute.For <IPlayerNotifier>(); var previousResult = runner.GetResult(typeof(IStringCalculator), typeof(KataData.StringCalculator.Tests.TestStringCalculator), typeof(NewTestWrittenWithoutAPassingTestForPreviousImplementation.StringCalculator), typeof(TestStringCalculator), kataImplementationTypes.ToArray()); var result = runner.GetResult(typeof(IStringCalculator), typeof(KataData.StringCalculator.Tests.TestStringCalculator), typeof(StringCalculator_002), typeof(TestStringCalculator_002), kataImplementationTypes.ToArray()); var processor = new AnalysisResultProcessor(Substitute.For <ISettingsManager>()); var attemptGameState = new AttemptGameState(new List <Result>(), Substitute.For <IKataHelper>()); attemptGameState.SetLatestResult(previousResult); //---------------Assert Precondition---------------- Assert.AreEqual(1, previousResult.PlayerImplementationLevel); Assert.AreEqual(2, previousResult.PlayerTestLevel); //---------------Execute Test ---------------------- processor.ProcessAnalysisResult(notifier, result, null, attemptGameState); //---------------Test Result ----------------------- Assert.AreEqual(2, result.PlayerImplementationLevel); Assert.AreEqual(3, result.PlayerTestLevel); const string expectedMessage = "You have written a test without first running tests after writing your previous implementation. Please undo or comment out your current test and run your tests"; notifier.Received().DisplayMessage("Test State", expectedMessage, NotifyIcon.Warning, NotifyIcon.Red); }
public void UseCommonSetupAndTearDown() { runner = new Runner.Runner( OnSetupsFinished, () => { }, OnTearDownsFinished, OnDependenciesSetupsFinished, OnDependenciesTearDownsFinished); runner.AddCase( typeof(UseCommonSetupAndTearDownOne)); runner.AddCase( typeof(UseCommonSetupAndTearDownTwo)); // Act. runner.Start(); // Assert. new[] { _dependenciesSetupsCounters.Count(), _dependenciesTearDownsCounters.Count() }.Should() .AllBeEquivalentTo(1, because: "There should be just one call to each of the dependencies setups and teardowns."); _dependenciesSetupsCounters.Max().Should() .BeLessThan(_dependenciesTearDownsCounters.Min(), because: "All dependency Setups should be run before teh dependency Teardowns."); _dependenciesSetupsCounters.Max().Should() .BeLessThan(_testSetupsCounters.Min(), because: "All dependency setups must be run before all test setups."); _testTearDownsCounters.Max().Should() .BeLessThan(_dependenciesTearDownsCounters.Min(), because: "All tests must have been teared down before all dependency teardowns."); }
public void Test1() { var runner = new Runner.Runner( () => { }, () => { }, () => { }, () => { }, () => { }); runner.AddCase(typeof(CanLoad)); runner.Start(); }
public void GetResult_GivenFailingTestForTwoNumbers_ShouldReturnContinueResult() { //---------------Set up test pack------------------- var configuration = new Configuration(); var kataImplementationTypes = configuration.GetKataImplementationTypes(); var runner = new Runner.Runner("", "", ""); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = runner.GetResult(typeof(IStringCalculator), typeof(KataData.StringCalculator.Tests.TestStringCalculator), typeof(UnknownStateTwoNumbers.StringCalculator), typeof(UnknownStateTwoNumbers.TestStringCalculator), kataImplementationTypes.ToArray()); //---------------Test Result ----------------------- Assert.AreEqual(4, result.PlayerImplementationLevel); Assert.AreEqual(4, result.PlayerTestLevel); Assert.AreEqual("You’ve written a valid failing test; please continue to write the implementation that will get this test to pass.", result.PlayerFeedback.Progress); }
public void GetResult_GivenAnotherPassingTestForTwoNumbers_ShouldReturnNotAllEdgeCasesTestedResult() { //---------------Set up test pack------------------- var configuration = new Configuration(); var kataImplementationTypes = configuration.GetKataImplementationTypes(); var runner = new Runner.Runner("", "", ""); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = runner.GetResult(typeof(IStringCalculator), typeof(KataData.StringCalculator.Tests.TestStringCalculator), typeof(UnknownStateTwoNumbers3.StringCalculator), typeof(UnknownStateTwoNumbers3.TestStringCalculator), kataImplementationTypes.ToArray()); //---------------Test Result ----------------------- Assert.AreEqual(4, result.PlayerImplementationLevel); Assert.AreEqual(4, result.PlayerTestLevel); var expectedMessage = "Success! Your test is passing. It is good practice to ensure that you are testing edge cases – can you find another edge case that should be tested in this same scenario?"; Assert.AreEqual(expectedMessage, result.PlayerFeedback.Progress); }
public void GetResult_GivenPassingTestForMultiCharCustomDelimiter_ShouldReturnNotAllEdgeCasesTestedResult() { //---------------Set up test pack------------------- var configuration = new Configuration(); var kataImplementationTypes = configuration.GetKataImplementationTypes(); var runner = new Runner.Runner("", "", ""); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = runner.GetResult(typeof(IStringCalculator), typeof(KataData.StringCalculator.Tests.TestStringCalculator), typeof(SpecificTestNegativeNumbers.StringCalculator), typeof(SpecificTestNegativeNumbers.TestStringCalculator), kataImplementationTypes.ToArray()); //---------------Test Result ----------------------- Assert.AreEqual(6, result.PlayerImplementationLevel); Assert.AreEqual(8, result.PlayerTestLevel); var expectedMessage = "Success! Your test is passing. To improve your implementation to be more generic, write another test for the same scenario with different values and then go on to get that test to pass too."; Assert.AreEqual(expectedMessage, result.PlayerFeedback.Progress); }
static void RunTests(string[] inputs, string reporterName) { if (testsRunning) { return; } testsRunning = true; AbstractReporter reporter = CreateReporter(reporterName); Runner.Runner runner = new Runner.Runner(reporter); AssemblyLoader loader = new AssemblyLoader(runner); foreach (string assemblyPath in inputs) { loader.Load(assemblyPath); } runner.Run(); testsRunning = false; }
static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve; try { runner = new Runner.Runner(); _vm = new ViewModel(runner); if (!ParseArguments(args)) { return; } var products = Runner.Runner.FindRevit(); if (products == null) { return; } runner.Products.AddRange(products); if (runner.Gui) { LoadSettings(); if (!string.IsNullOrEmpty(runner.TestAssembly) && File.Exists(runner.TestAssembly)) { runner.Refresh(); } // Show the user interface var view = new View(_vm); view.ShowDialog(); SaveSettings(); } else { if (string.IsNullOrEmpty(runner.RevitPath)) { runner.RevitPath = Path.Combine(runner.Products.First().InstallLocation, "revit.exe"); } if (string.IsNullOrEmpty(runner.WorkingDirectory)) { runner.WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } // In any case here, the test assembly cannot be null if (string.IsNullOrEmpty(runner.TestAssembly)) { Console.WriteLine("You must specify at least a test assembly."); return; } var assemblyDatas = Runner.Runner.ReadAssembly(runner.TestAssembly, runner.WorkingDirectory); if (assemblyDatas == null) { return; } runner.Assemblies.Clear(); runner.Assemblies.AddRange(assemblyDatas); if (File.Exists(runner.Results) && !runner.Concat) { File.Delete(runner.Results); } Console.WriteLine(runner.ToString()); if (string.IsNullOrEmpty(runner.Fixture) && string.IsNullOrEmpty(runner.Test)) { runner.RunCount = runner.Assemblies.SelectMany(a => a.Fixtures.SelectMany(f => f.Tests)).Count(); foreach (var ad in runner.Assemblies) { runner.RunAssembly(ad); } } else if (string.IsNullOrEmpty(runner.Test) && !string.IsNullOrEmpty(runner.Fixture)) { var fd = runner.Assemblies.SelectMany(x => x.Fixtures).FirstOrDefault(f => f.Name == runner.Fixture); if (fd != null) { runner.RunCount = fd.Tests.Count; runner.RunFixture(fd); } } else if (string.IsNullOrEmpty(runner.Fixture) && !string.IsNullOrEmpty(runner.Test)) { var td = runner.Assemblies.SelectMany(a => a.Fixtures.SelectMany(f => f.Tests)) .FirstOrDefault(t => t.Name == runner.Test); if (td != null) { runner.RunCount = 1; runner.RunTest(td); } } } runner.Cleanup(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
async Task DoWorkAsync(CancellationToken cancellationToken) { using (var runner = new Runner.Runner()) { try { runner.Log += InvokeLog; runner.ExceptionThrown += InvokeExceptionThrown; await runner.RunAsync(cancellationToken); } finally { runner.ExceptionThrown -= InvokeExceptionThrown; runner.Log -= InvokeLog; } } }
static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve; try { runner = new Runner.Runner(); _vm = new ViewModel(runner); if (!ParseArguments(args)) { return; } var products = Runner.Runner.FindRevit(); if (products == null) { return; } runner.Products.AddRange(products); if (runner.Gui) { LoadSettings(); if (!string.IsNullOrEmpty(runner.TestAssembly) && File.Exists(runner.TestAssembly)) { runner.Refresh(); } // Show the user interface var view = new View(_vm); view.ShowDialog(); SaveSettings(); } else { if (string.IsNullOrEmpty(runner.RevitPath)) { runner.RevitPath = Path.Combine(runner.Products.First().InstallLocation, "revit.exe"); } if (string.IsNullOrEmpty(runner.WorkingDirectory)) { runner.WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } // In any case here, the test assembly cannot be null if (string.IsNullOrEmpty(runner.TestAssembly)) { Console.WriteLine("You must specify at least a test assembly."); return; } var assemblyDatas = Runner.Runner.ReadAssembly(runner.TestAssembly, runner.WorkingDirectory); if (assemblyDatas == null) { return; } runner.Assemblies.Clear(); runner.Assemblies.AddRange(assemblyDatas); if (File.Exists(runner.Results) && !runner.Concat) { File.Delete(runner.Results); } Console.WriteLine(runner.ToString()); if (string.IsNullOrEmpty(runner.Fixture) && string.IsNullOrEmpty(runner.Test)) { runner.RunCount = runner.Assemblies.SelectMany(a => a.Fixtures.SelectMany(f => f.Tests)).Count(); foreach (var ad in runner.Assemblies) { runner.RunAssembly(ad); } } else if (string.IsNullOrEmpty(runner.Test) && !string.IsNullOrEmpty(runner.Fixture)) { var fd = runner.Assemblies.SelectMany(x => x.Fixtures).FirstOrDefault(f => f.Name == runner.Fixture); if (fd != null) { runner.RunCount = fd.Tests.Count; runner.RunFixture(fd); } } else if (string.IsNullOrEmpty(runner.Fixture) && !string.IsNullOrEmpty(runner.Test)) { var td = runner.Assemblies.SelectMany(a => a.Fixtures.SelectMany(f => f.Tests)) .FirstOrDefault(t => t.Name == runner.Test); if (td != null) { runner.RunCount = 1; runner.RunTest(td); } } } runner.Cleanup(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public AssemblyLoader(Runner.Runner runner) { this.runner = runner; }