public void TestAddTestAssemblyAsyncWithAssemblyNotAlreadyAddedLoadsAndAddsAssemblyAndReturnsAddedTest( [Values] bool withSettings) { string workingDirectory = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..")); string expectedDirectory = withSettings ? workingDirectory : Directory.GetCurrentDirectory(); Dictionary <string, object> settings = withSettings ? new Dictionary <string, object> { { FrameworkPackageSettings.WorkDirectory, workingDirectory } } : null; INUnitRunner runner = new NUnitRunner("suite-name"); Assembly assembly = typeof(TestFixtureStubOne).Assembly; List <Assembly> expectedAssemblies = new List <Assembly> { assembly }; Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly, settings); Assert.IsNotNull(testTask); testTask.Wait(); ITest test = testTask.Result; Assert.IsNotNull(test); Assert.AreEqual(RunState.Runnable, test.RunState); Assert.AreEqual("XamarinNUnitRunner.Test.Stub.dll", test.Name); Assert.IsTrue(runner.TestSuite.ContainsAssembly(assembly)); Assert.IsTrue(runner.TestSuite.GetTestAssemblyRunner(assembly).IsTestLoaded); Assert.AreEqual(expectedDirectory, TestContext.CurrentContext.WorkDirectory); CollectionAssert.AreEquivalent(expectedAssemblies, runner.TestSuite.TestAssemblies); }
public void TestCountTestCasesAsyncReturnsNumberOfTestCasesLoaded([Values] bool withChildTests, [Values] bool withFilter) { ITestFilter filter = withFilter ? NUnitFilter.Where.Class(typeof(TestFixtureStubOne).FullName).And.Method("Test2").Build().Filter : null; INUnitRunner runner = new NUnitRunner("suite-name"); Assembly assembly = typeof(TestFixtureStubOne).Assembly; int expected = 0; if (withChildTests) { expected = withFilter ? 1 : TestFixtureStubHelper.GeTestFixtureStub().TestCount; Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly); testTask.Wait(); } Task <int> countTask = runner.CountTestCasesAsync(filter); Assert.IsNotNull(countTask); countTask.Wait(); int count = countTask.Result; Assert.AreEqual(expected, count); }
public void RunNUnitConsole() { var ctx = ScenarioContext.Current.GetTestContext(); var configuration = ctx.GetOrCreateNUnitConfiguration(); var runner = new NUnitRunner(); ICommandLineSetupFactory setupFactory; switch (configuration.ConfigurationType) { case ConfigurationType.CmdArguments: setupFactory = new ArgumentsCommandLineSetupFactory(); break; case ConfigurationType.ProjectFile: setupFactory = new ProjectCommandLineSetupFactory(); break; default: throw new ArgumentOutOfRangeException(); } var testSession = runner.Run(ctx, setupFactory.Create(ctx)); ctx.TestSession = testSession; }
public void BuildArgs_ShouldConstructWithFileToTest() { string pathToFile = "c:\\test.dll"; var subject = new NUnitRunner().FileToTest(pathToFile); subject.BuildArgs(); Assert.That(subject._argumentBuilder.Build(), Is.EqualTo(pathToFile + " /nologo /nodots /xmlconsole" )); }
/// <summary> /// Explore a test assembly. /// </summary> private void Explore(ExploreRequest request, Response response) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (response == null) { throw new ArgumentNullException(nameof(response)); } NUnitRunner runner = new NUnitRunner(request.AssemblyPath, response.Directory); string message = runner.ExploreAssembly(); runner.Dispose(); ExploreResponse exploreResponse = new ExploreResponse { Timestamp = DateTime.Now, Id = request.Id, AssemblyPath = request.AssemblyPath, ExploreFile = runner.ExploreResultFile, Message = message }; JsonHelper.ToFile(Path.Combine(response.Directory, FileNames.ExploreResponseFileName), exploreResponse); }
public void TestTestPropertyCanBeSetAndDoesNotInvokePropertyChangedEventIfSetValueIsSameAsCurrentValue( [Values] bool withTest) { int invocationCount = 0; NUnitRunner runner = new NUnitRunner("runner-name"); TestSuite suite = new TestSuite("suite-name"); ITest testInstance = suite; ITest test = withTest ? testInstance : null; string expectedTitle = withTest ? testInstance.FullName : runner.TestSuite.FullName; TestsViewModel model = new TestsViewModel(runner, test); model.PropertyChanged += (s, a) => { invocationCount++; }; Assert.AreEqual(test, model.Test); Assert.AreEqual(expectedTitle, model.Title); Assert.AreEqual(0, invocationCount); model.Test = test; Assert.AreEqual(test, model.Test); Assert.AreEqual(expectedTitle, model.Title); Assert.AreEqual(0, invocationCount); }
public void TestReloadResultsCommandReturnsImmediatelyWhenTestRunnerIsNull() { int invocationCount = 0; NUnitRunner runner = new NUnitRunner("runner-name"); runner.AddTestAssembly(typeof(TestFixtureStubOne).Assembly); TestsViewModel model = new TestsViewModel(null, runner.TestSuite); model.PropertyChanged += (sender, args) => { if (args.PropertyName.Equals("IsBusy")) { invocationCount++; } }; model.ReloadResultsCommand.Execute(null); WaitForCommand(model); Assert.IsFalse(model.IsBusy); Assert.AreEqual(0, invocationCount); CollectionAssert.IsEmpty(model.Tests); }
public static void Main(string[] args) { NUnitRunner runner = new NUnitRunner(args); runner.AddGlobalSetupIfNeeded("GVFS.UnitTests.Setup"); List <string> excludeCategories = new List <string>(); if (Debugger.IsAttached) { excludeCategories.Add(CategoryConstants.ExceptionExpected); } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { excludeCategories.Add(CategoryConstants.CaseInsensitiveFileSystemOnly); } else { excludeCategories.Add(CategoryConstants.CaseSensitiveFileSystemOnly); } Environment.ExitCode = runner.RunTests(includeCategories: null, excludeCategories: excludeCategories); if (Debugger.IsAttached) { Console.WriteLine("Tests completed. Press Enter to exit."); Console.ReadLine(); } }
public void TestExploreTestsAsyncWithAssemblyReturnsLoadedTestCases([Values] bool withChildTests, [Values] bool withFilter) { ITestFilter filter = withFilter ? NUnitFilter.Where.Class(typeof(TestFixtureStubOne).FullName).And.Method("Test2").Build().Filter : null; INUnitRunner runner = new NUnitRunner("suite-name"); Assembly assembly = typeof(TestFixtureStubOne).Assembly; int expected = 0; if (withChildTests) { expected = withFilter ? 1 : TestFixtureStubHelper.GeTestFixtureStub().TestCount; Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly); testTask.Wait(); } Task <ITest> exploreTask = runner.ExploreTestsAsync(assembly, filter); Assert.IsNotNull(exploreTask); exploreTask.Wait(); ITest test = exploreTask.Result; if (withChildTests) { Assert.IsNotNull(test); Assert.AreEqual(expected, test.TestCaseCount); } else { Assert.IsNull(test); } }
public void TestResultPropertyCanBeSetAndDoesNotInvokePropertyChangedEventIfSetValueIsSameAsCurrentValue( [Values] bool withResult, [Values] bool withTest) { int invocationCount = 0; NUnitRunner runner = new NUnitRunner("runner-name"); TestSuite suite = new TestSuite("suite-name"); INUnitTestResult result = withResult ? new NUnitTestResult(new TestSuiteResult(suite)) : null; ITest test = withTest ? suite : null; TestsViewModel model = new TestsViewModel(runner, test); model.Result = result; model.PropertyChanged += (s, a) => { invocationCount++; }; Assert.AreEqual(result, model.Result); Assert.AreEqual(0, invocationCount); model.Result = result; Assert.AreEqual(result, model.Result); Assert.AreEqual(test, model.Test); Assert.AreEqual(0, invocationCount); }
public void TestAddTestAssemblyWithAssemblyAlreadyAddedDoesNotReAddAssemblyAndReturnsAlreadyAddedAssembly() { INUnitRunner runner = new NUnitRunner("suite-name"); Assembly assembly = typeof(TestFixtureStubOne).Assembly; List <Assembly> expectedAssemblies = new List <Assembly> { assembly }; ITest testInitial = runner.AddTestAssembly(assembly); Assert.IsNotNull(testInitial); Assert.AreEqual(RunState.Runnable, testInitial.RunState); Assert.AreEqual("XamarinNUnitRunner.Test.Stub.dll", testInitial.Name); Assert.IsTrue(runner.TestSuite.ContainsAssembly(assembly)); Assert.IsTrue(runner.TestSuite.GetTestAssemblyRunner(assembly).IsTestLoaded); CollectionAssert.AreEquivalent(expectedAssemblies, runner.TestSuite.TestAssemblies); ITest test = runner.AddTestAssembly(assembly); Assert.IsNotNull(test); Assert.AreSame(testInitial, test); Assert.AreEqual(RunState.Runnable, test.RunState); Assert.AreEqual("XamarinNUnitRunner.Test.Stub.dll", test.Name); Assert.IsTrue(runner.TestSuite.ContainsAssembly(assembly)); Assert.IsTrue(runner.TestSuite.GetTestAssemblyRunner(assembly).IsTestLoaded); CollectionAssert.AreEquivalent(expectedAssemblies, runner.TestSuite.TestAssemblies); }
public void TestLoadTestsCommandClearsAndReturnsWhenTestHasNoChildren() { int invocationCount = 0; NUnitRunner runner = new NUnitRunner("runner-name"); ITest test = runner.TestSuite; TestsViewModel model = new TestsViewModel(runner, test); model.PropertyChanged += (sender, args) => { if (args.PropertyName.Equals("IsBusy")) { invocationCount++; } }; model.LoadTestsCommand.Execute(null); WaitForCommand(model); Assert.IsFalse(model.IsBusy); Assert.IsNotNull(model.Test); Assert.IsNotNull(model.Test); Assert.IsFalse(model.Test.HasChildren); Assert.AreEqual(2, invocationCount); CollectionAssert.IsEmpty(model.Tests); }
public void AddParameter_ShouldAddToInteralDictionary() { var subject = new NUnitRunner(); string param = "singleParam"; string value = "val"; NUnitRunner nUnitRunner = subject.AddParameter(param,value); Assert.That(nUnitRunner, Is.SameAs(subject)); Assert.That(nUnitRunner._argumentBuilder.FindByName(param), Is.EqualTo(value )); }
public void AddSingleParameter_ShouldAddToInteralDictionary() { var subject = new NUnitRunner(); string singleparam = "singleParam"; NUnitRunner nUnitRunner = subject.AddParameter(singleparam); subject.BuildArgs(); Assert.That(nUnitRunner, Is.SameAs(subject)); Assert.That(nUnitRunner._argumentBuilder.FindByName(singleparam), Is.EqualTo(null)); }
public void BuildArgs_ShouldConstructWithFileToTestAndNameValueParameter() { string pathToFile = "c:\\test.dll"; string name = "label"; string value = "value"; var subject = new NUnitRunner().FileToTest(pathToFile).AddParameter(name,value); subject.BuildArgs(); Assert.That(subject._argumentBuilder.Build(), Is.EqualTo(pathToFile + " /" + name + ":" + value + " /nologo /nodots /xmlconsole")); }
public void TestGetTestResultsThrowsArgumentNullExceptionWhenAssemblyIsNull() { INUnitRunner runner = new NUnitRunner("suite-name"); Assert.Throws( Is.TypeOf <ArgumentNullException>().And.Message .EqualTo("The assembly cannot be null. (Parameter 'assembly')"), () => runner.GetTestResults(null)); }
public void TestRunTestsAsyncWithAssemblyRunsTestsAndReturnsTheRanTests([Values] bool withChildTests, [Values] bool withListener, [Values] bool withFilter) { ITestFilter filter = withFilter ? NUnitFilter.Where.Class(typeof(TestFixtureStubOne).FullName).And.Method("Test2").Build().Filter : null; ResultState expectedState = ResultState.Inconclusive; if (withChildTests) { expectedState = withFilter ? ResultState.Success : ResultState.ChildFailure; } TestListenerForTest listener = withListener ? new TestListenerForTest() : null; INUnitRunner runner = new NUnitRunner("suite-name"); Assembly assembly = typeof(TestFixtureStubOne).Assembly; int expectedCaseCount = 0; int expectedResultCount = 0; if (withChildTests) { expectedCaseCount = TestFixtureStubHelper.GeTestFixtureStub().ResultsDepth + (withFilter ? 2 : TestFixtureStubHelper.GeTestFixtureStub().ResultCount); expectedResultCount = withFilter ? 1 : TestFixtureStubHelper.GeTestFixtureStub().TestCount; Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly); testTask.Wait(); } Task <ITestResult> testsTask = runner.RunTestsAsync(assembly, listener, filter); Assert.IsNotNull(testsTask); testsTask.Wait(); ITestResult results = testsTask.Result; if (withChildTests) { Assert.IsNotNull(results); Assert.IsFalse(runner.IsTestRunning); Assert.IsTrue(runner.IsTestComplete); Assert.AreEqual(expectedState, results.ResultState); int totalResultCount = results.FailCount + results.InconclusiveCount + results.PassCount + results.SkipCount + results.WarningCount; Assert.AreEqual(expectedResultCount, totalResultCount); if (withListener) { Assert.AreEqual(expectedCaseCount, listener.Tests.Count); } } else { Assert.IsNull(results); } }
public void TestRunTestsAsyncThrowsArgumentNullExceptionWhenAssemblyIsNull() { INUnitRunner runner = new NUnitRunner("suite-name"); Assert.ThrowsAsync( Is.TypeOf <ArgumentNullException>().And.Message .EqualTo("The assembly cannot be null. (Parameter 'assembly')"), async() => await runner.RunTestsAsync(null, null, null)); }
public void TestConstructorWithName() { const string name = "suite-name"; NUnitRunner runner = new NUnitRunner(name); Assert.IsNotNull(runner.TestSuite); Assert.AreEqual(name, runner.TestSuite.Name); Assert.AreEqual(name, runner.TestSuite.FullName); }
public void TestOnItemSelectedWithSelectedItemTestWithoutChildTestsPushesTestDetailPageToStackAndCaches() { NUnitRunner runner = new NUnitRunner("runner-name"); runner.AddTestAssembly(typeof(TestFixtureStubOne).Assembly); IMethodInfo methodOne = new MethodWrapper(typeof(TestsPageTest), GetType().GetMethods().First()); IMethodInfo methodTwo = new MethodWrapper(typeof(TestsPageTest), GetType().GetMethods().Last()); ITest firstTestInstance = new TestMethod(methodOne); ITest secondTestInstance = new TestMethod(methodTwo); TestsViewModel firstTest = new TestsViewModel(runner, firstTestInstance); TestsViewModel secondTest = new TestsViewModel(runner, secondTestInstance); Assert.IsFalse(firstTest.Test.IsSuite); Assert.IsFalse(firstTest.Test.HasChildren); Assert.IsFalse(secondTest.Test.IsSuite); Assert.IsFalse(secondTest.Test.HasChildren); SelectedItemChangedEventArgs firstArgs = new SelectedItemChangedEventArgs(firstTest, 0); SelectedItemChangedEventArgs secondArgs = new SelectedItemChangedEventArgs(secondTest, 0); TestsPageForTest page = new TestsPageForTest(runner); // Load first page page.InvokeOnItemSelected(null, firstArgs); Assert.AreEqual(1, page.NavigationStack.Count); TestDetailPage firstTestsPage = page.NavigationStack.First() as TestDetailPage; Assert.IsNotNull(firstTestsPage); Assert.AreEqual(firstTest, firstTestsPage.ViewModel); Assert.AreEqual(runner, firstTestsPage.ViewModel.TestRunner); Assert.AreEqual(firstTestInstance, firstTestsPage.ViewModel.Test); // Load second page page.InvokeOnItemSelected(null, secondArgs); Assert.AreEqual(2, page.NavigationStack.Count); TestDetailPage secondTestsPage = page.NavigationStack[1] as TestDetailPage; Assert.IsNotNull(secondTestsPage); Assert.AreEqual(secondTest, secondTestsPage.ViewModel); Assert.AreEqual(runner, secondTestsPage.ViewModel.TestRunner); Assert.AreEqual(secondTestInstance, secondTestsPage.ViewModel.Test); // Load first page again IList <Page> expectedStack = new List <Page>(page.NavigationStack); expectedStack.Add(firstTestsPage); page.InvokeOnItemSelected(null, firstArgs); Assert.AreEqual(3, page.NavigationStack.Count); Assert.AreSame(firstTestsPage, page.NavigationStack[2]); CollectionAssert.AreEqual(expectedStack, page.NavigationStack); }
private void btnCodeCoverage_Click(object sender, EventArgs e) { NUnitRunner nUnitRunner = new NUnitRunner(@"opencover.4.6.519\OpenCover.Console.exe", @"NUnit.Console-3.8.0\nunit3-console.exe"); nUnitRunner.RunDLL(((KeyValuePair<string, string>)cbDll.SelectedItem).Value, "coverage.xml"); ReportGenerator reportGenerator = new ReportGenerator(@"ReportGenerator_3.1.2.0\ReportGenerator.exe"); reportGenerator.Generate("coverage.xml", txtSourceDirectory.Text); Browser browser = new Browser("index.htm"); browser.Show(); }
public void TestConstructorWithNUnitRunner([Values] bool isRunnerNull, [Values] bool isTestNull) { NUnitRunner runner = isRunnerNull ? null : new NUnitRunner("runner-name"); TestsViewModel test = isTestNull ? null : new TestsViewModel(runner, new NUnitSuite("suite-name")); TestDetailPage page = new TestDetailPage(test, false); Assert.AreSame(test, page.ViewModel); Assert.AreSame(test?.TestRunner, page.ViewModel?.TestRunner); Assert.AreSame(test?.Test, page.ViewModel?.Test); }
public static void Main(string[] args) { NUnitRunner runner = new NUnitRunner(args); if (Debugger.IsAttached) { runner.ExcludeCategory(CategoryContants.ExceptionExpected); } Environment.ExitCode = runner.RunTests(1); }
public void TestOnItemSelectedWithEventArgsOrSelectedItemNullReturnsImmediately([Values] bool isArgNull) { SelectedItemChangedEventArgs args = isArgNull ? null : new SelectedItemChangedEventArgs(null, 0); NUnitRunner runner = new NUnitRunner("runner-name"); TestsPageForTest page = new TestsPageForTest(runner); page.InvokeOnItemSelected(null, args); CollectionAssert.IsEmpty(page.NavigationStack); }
public void TestOnItemSelectedWithSelectedItemNotTestTypeReturnsImmediately() { SelectedItemChangedEventArgs args = new SelectedItemChangedEventArgs("Hello", 0); NUnitRunner runner = new NUnitRunner("runner-name"); TestsPageForTest page = new TestsPageForTest(runner); page.InvokeOnItemSelected(null, args); CollectionAssert.IsEmpty(page.NavigationStack); }
public MainPage() { InitializeComponent(); // TODO - Initialize test runner and add test assembly references NUnitRunner runner = new NUnitRunner(GetType().Namespace); runner.AddTestAssembly(typeof(Test.Stub.TestFixtureStubOne).Assembly); XamarinNUnitRunner.App app = new XamarinNUnitRunner.App(runner); LoadApplication(app); }
public static void Main(string[] args) { NUnitRunner runner = new NUnitRunner(args); if (runner.HasCustomArg("--full-suite")) { Console.WriteLine("Running the full suite of tests"); FileSystemRunners.FileSystemRunner.UseAllRunners = true; } Environment.ExitCode = runner.RunTests(Properties.Settings.Default.TestRepeatCount); }
public static void Main(string[] args) { NUnitRunner runner = new NUnitRunner(args); if (runner.HasCustomArg("--no-shared-gvfs-cache")) { Console.WriteLine("Running without a shared git object cache"); GVFSTestConfig.NoSharedCache = true; } GVFSTestConfig.LocalCacheRoot = runner.GetCustomArgWithParam("--shared-gvfs-cache-root"); if (runner.HasCustomArg("--full-suite")) { Console.WriteLine("Running the full suite of tests"); GVFSTestConfig.UseAllRunners = true; } GVFSTestConfig.RepoToClone = runner.GetCustomArgWithParam("--repo-to-clone") ?? Properties.Settings.Default.RepoToClone; string servicePath = Path.Combine(TestContext.CurrentContext.TestDirectory, Properties.Settings.Default.PathToGVFSService); GVFSServiceProcess.InstallService(servicePath); try { Environment.ExitCode = runner.RunTests(Properties.Settings.Default.TestRepeatCount); } finally { string serviceLogFolder = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GVFS", GVFSServiceProcess.TestServiceName, "Logs"); Console.WriteLine("GVFS.Service logs at '{0}' attached below.\n\n", serviceLogFolder); foreach (string filename in TestResultsHelper.GetAllFilesInDirectory(serviceLogFolder)) { TestResultsHelper.OutputFileContents(filename); } GVFSServiceProcess.UninstallService(); } if (Debugger.IsAttached) { Console.WriteLine("Tests completed. Press Enter to exit."); Console.ReadLine(); } }
public void TestResultPropertyCanBeSetAndInvokesPropertyChangedEventIfSetValueIsNotSameAsCurrentValue( [Values] bool withResult, [Values] bool isChangedEventNull) { object sender = null; PropertyChangedEventArgs args = null; int invocationCount = 0; int expectedCount = isChangedEventNull ? 0 : 1; NUnitRunner runner = new NUnitRunner("runner-name"); TestSuite test = new TestSuite("suite-name"); INUnitTestResult result = withResult ? null : new NUnitTestResult(new TestSuiteResult(test)); TestsViewModel model = new TestsViewModel(runner, test, result); INUnitTestResult initialResult = withResult ? new NUnitTestResult(new TestSuiteResult(new TestSuite("suite-name2"))) : null; model.Result = initialResult; IList <string> changedProps = new List <string>(); if (!isChangedEventNull) { model.PropertyChanged += (s, a) => { changedProps.Add(a.PropertyName); if (a.PropertyName.Equals("Result")) { sender = s; args = a; invocationCount++; } }; } Assert.AreEqual(initialResult, model.Result); Assert.AreEqual(0, invocationCount); model.Result = result; Assert.AreEqual(result, model.Result); Assert.AreEqual(test, model.Test); Assert.AreEqual(expectedCount, invocationCount); if (!isChangedEventNull) { Assert.IsNotNull(sender); Assert.AreSame(model, sender); Assert.IsNotNull(args); Assert.AreEqual("Result", args.PropertyName); CollectionAssert.AreEquivalent(new[] { "Result", "HasResult" }, changedProps); } }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Xamarin.Forms.Forms.Init(); // TODO - Initialize test runner and add test assembly references NUnitRunner runner = new NUnitRunner(GetType().Namespace); runner.AddTestAssembly(typeof(Test.Stub.TestFixtureStubOne).Assembly); LoadApplication(new App(runner)); return(base.FinishedLaunching(app, options)); }
private void NUnit2Test(List <FilePath> assemblies, FilePath outputFile, string excludeFilter) { var settings = new NUnitSettings { NoLogo = true, NoResults = IsInteractiveBuild, ResultsFile = outputFile, Exclude = excludeFilter }; var runner = new NUnitRunner(_fileSystem, _environment, _processRunner, _tools); runner.Run(assemblies, settings); }
public void TestOnItemSelectedWithSelectedItemTestIdIsNullOrEmptyReturnsImmediately([Values] bool isNull) { TestForTest test = new TestForTest(); test.Id = isNull ? null : string.Empty; SelectedItemChangedEventArgs args = new SelectedItemChangedEventArgs(test, 0); NUnitRunner runner = new NUnitRunner("runner-name"); TestsPageForTest page = new TestsPageForTest(runner); page.InvokeOnItemSelected(null, args); CollectionAssert.IsEmpty(page.NavigationStack); }
public void TestConstructorWithNUnitRunner([Values] bool isRunnerNull) { NUnitRunner runner = isRunnerNull ? null : new NUnitRunner("runner-name"); MainPage page = new MainPage(runner, false); Assert.IsNotNull(page.Detail); Page detailPage = (page.Detail as NavigationPage)?.RootPage; Assert.IsNotNull(detailPage); TestsPage testsPage = detailPage as TestsPage; Assert.IsNotNull(testsPage); Assert.IsNotNull(page.Master); Assert.IsTrue(page.Master is MenuPage); }
public void TestGetTestResultsAsyncWithAssemblyReturnsResults([Values] bool withChildTests, [Values] bool runTests, [Values] bool withFilter) { ITestFilter filter = withFilter ? NUnitFilter.Where.Class(typeof(TestFixtureStubOne).FullName).And.Method("Test2").Build().Filter : null; ResultState expectedState = ResultState.Inconclusive; if (withChildTests && runTests) { expectedState = withFilter ? ResultState.Success : ResultState.ChildFailure; } INUnitRunner runner = new NUnitRunner("suite-name"); Assembly assembly = typeof(TestFixtureStubOne).Assembly; int expectedCount = 0; if (withChildTests) { expectedCount = withFilter ? 1 : TestFixtureStubHelper.GeTestFixtureStub().TestCount; Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly); testTask.Wait(); } if (runTests) { runner.RunTests(null, filter); } else { expectedCount = 0; } Task <ITestResult> resultTask = runner.GetTestResultsAsync(assembly); Assert.IsNotNull(resultTask); resultTask.Wait(); ITestResult results = resultTask.Result; Assert.IsNotNull(results); Assert.AreEqual(expectedState, results.ResultState); int totalCount = results.FailCount + results.InconclusiveCount + results.PassCount + results.SkipCount + results.WarningCount; Assert.AreEqual(expectedCount, totalCount); }
public void Execute_ShouldCallExecuteMethodOnMock() { string pathToExe = "c:\\test.exe"; var mockExecutable = MockRepository.GenerateStub<IExecutable>(); var mockFileFinder = MockRepository.GenerateStub<IFileSystemHelper>(); var subject = new NUnitRunner(mockExecutable, mockFileFinder); mockExecutable.Stub(x => x.ExecutablePath(pathToExe)).Return(mockExecutable); mockExecutable.Stub(x => x.UseArgumentBuilder(null)).IgnoreArguments().Return(mockExecutable); mockExecutable.Stub(x => x.SucceedOnNonZeroErrorCodes()).IgnoreArguments().Return(mockExecutable); mockExecutable.Stub(x => x.FailOnError).IgnoreArguments().Return(mockExecutable); mockExecutable.Stub(x => x.ContinueOnError).IgnoreArguments().Return(mockExecutable); mockExecutable.Stub(x => x.WithMessageProcessor(Arg<IMessageProcessor>.Is.Anything)).Return(mockExecutable); subject.PathToNunitConsoleRunner(pathToExe).InternalExecute(); mockExecutable.AssertWasCalled(x=>x.Execute()); }
public void XmlOutputTo_ShouldPopulatePropertiesAndReturnSelf() { var subject = new NUnitRunner(); string file = "c:\\temp\\out.xml"; NUnitRunner nUnitRunner = subject.XmlOutputTo(file); Assert.That(nUnitRunner, Is.SameAs(subject)); Assert.That(nUnitRunner._argumentBuilder.FindByName("xml"), Is.EqualTo(file)); }
public void WorkingDirectory_ShouldPopulateInternalFieldAndReturnSelf() { var subject = new NUnitRunner(); string workingdir = "workingDir"; NUnitRunner nUnitRunner = subject.WorkingDirectory(workingdir); Assert.That(nUnitRunner, Is.SameAs(subject)); Assert.That(nUnitRunner._workingDirectory, Is.EqualTo(workingdir)); }
public void PathToConsoleRunner_ShouldPopulateInternalFieldAndReturnSelf() { var subject = new NUnitRunner(); string file = "c:\\temp\\nunit-console.exe"; NUnitRunner nUnitRunner = subject.PathToNunitConsoleRunner(file); Assert.That(nUnitRunner, Is.SameAs(subject)); Assert.That(nUnitRunner._pathToConsoleRunner, Is.EqualTo(file)); }
public void FileToTest_ShouldPopulateInternalFieldAndReturnSelf() { var subject = new NUnitRunner(); string file = "file.dll"; NUnitRunner nUnitRunner = subject.FileToTest(file); Assert.That(nUnitRunner, Is.SameAs(subject)); Assert.That(nUnitRunner._fileToTest, Is.EqualTo(file)); }
public void Execute_ShouldTryToFindPathToNunitIfNotSet() { string workingDirectory = "c:\\temp"; string pathToExe = "c:\\test.exe"; var mockExecutable = MockRepository.GenerateStub<IExecutable>(); var mockFileFinder = MockRepository.GenerateStub<IFileSystemHelper>(); var subject = new NUnitRunner(mockExecutable, mockFileFinder); mockFileFinder.Stub(x => x.Find("nunit-console.exe")).Return("c:\\temp\nunit-console.exe"); mockExecutable.Stub(x => x.ExecutablePath(pathToExe)).IgnoreArguments().Return(mockExecutable); mockExecutable.Stub(x => x.UseArgumentBuilder(null)).IgnoreArguments().Return(mockExecutable); mockExecutable.Stub(x => x.SucceedOnNonZeroErrorCodes()).IgnoreArguments().Return(mockExecutable); mockExecutable.Stub(x => x.FailOnError).IgnoreArguments().Return(mockExecutable); mockExecutable.Stub(x => x.ContinueOnError).IgnoreArguments().Return(mockExecutable); mockExecutable.Stub(x => x.WithMessageProcessor(Arg<IMessageProcessor>.Is.Anything)).Return(mockExecutable); subject.Execute(); mockFileFinder.AssertWasCalled(x => x.Find("nunit-console.exe")); }
public void Execute_ShouldThrowExceptionIfPathToExeNotSetAndCanNotBeFound() { var mockExecutable = MockRepository.GenerateStub<IExecutable>(); var mockFileFinder = MockRepository.GenerateStub<IFileSystemHelper>(); var subject = new NUnitRunner(mockExecutable, mockFileFinder); mockFileFinder.Stub(x => x.Find("nunit-console.exe")).Return(null); subject.Execute(); }