Beispiel #1
0
        private void btnRunTests_Click(object sender, EventArgs e)
        {
            try
            {
                string platformId = Library.GetPlatformId();
                string path       = Library.GetLibraryPath();

                var fi = new FileInfo(path);

                lblLibVersion.Text = string.Format("{2}, {0}, {1}", platformId, fi.LastWriteTime.ToString("dd-MM-yyyy HH:mm:ss"), Path.GetFileName(path));
                lblLibVersion.Update();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message + "\r\n\r\n" + ex.StackTrace, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            var runner = new NUnitTestRunner();

            runner.RunTests(
                cbxCopyToClipboard.Checked,
                (i) => this.Invoke(new Action <int>(StartRunningTests), i),
                (i, j) => this.Invoke(new Action <int, int>(ProgressRunningTests), i, j),
                (i) => this.Invoke(new Action <int>(StopRunningTests), i));
        }
Beispiel #2
0
    public void RunTests()
    {
        Console.WriteLine("");
        Console.WriteLine("Running tests...");
        Console.WriteLine("");

        var binTestsDir = CurrentDirectory
                          + Path.DirectorySeparatorChar
                          + "bin-tests";

        Console.WriteLine("Bin tests dir:");
        Console.WriteLine(binTestsDir);

        // Move all the files into a new location where the tests can run
        // (without doing this, the scripts don't execute as tests because the general csAnt binaries aren't in the same folder)
        var workingDir = PrepareTests(binTestsDir);

        var runner = new NUnitTestRunner(
            this,
            BuildMode
            );

        // Exclude live tests during standard testing because most of the time they're not required and too slow during development.
        // They should be performed on their own when required
        runner.AddIncludeCategory("Live");

        runner.RunTestsInDirectory(workingDir);


        Directory.Delete(binTestsDir, true);
    }
        public async Task <IActionResult> PostAsync([FromBody] ExerciseSolution exerciseSolution, [FromServices] IDockerClient dockerClient)
        {
            var runner = new NUnitTestRunner(dockerClient);
            var result = await runner.Run(exerciseSolution);

            return(Ok(result));
        }
Beispiel #4
0
    public void RunTests()
    {
        var binTestsDir = CurrentDirectory
                          + Path.DirectorySeparatorChar
                          + "bin-tests";

        // Move all the files into a new location where the tests can run
        // (without doing this, the scripts don't execute as tests because the general csAnt binaries aren't in the same folder)
        var workingDir = PrepareTests(binTestsDir);

        var runner = new NUnitTestRunner(
            this,
            BuildMode
            );

        runner.AddIncludeCategory("TestScript");

        // Exclude live tests during standard testing because most of the time they're not required and too slow during development.
        // They should be performed on their own when required
        runner.AddExcludeCategory("Live");

        // Exclude sub tests otherwise it causes an infinite loop with a test being executed which executes all other tests, causing it to be re-executed each time
        // Sub tests can be executed separately
        runner.AddExcludeCategory("SubTests");

        runner.RunTestsInDirectory(workingDir);


        Directory.Delete(binTestsDir, true);
    }
        static int RunTests(string [] original_args)
        {
            Console.WriteLine("Running tests");
            var options = ApplicationOptions.Current;

            // we generate the logs in two different ways depending if the generate xml flag was
            // provided. If it was, we will write the xml file to the tcp writer if present, else
            // we will write the normal console output using the LogWriter
            var logger = new LogWriter(Console.Out);

            logger.MinimumLogLevel = MinimumLogLevel.Info;
            var        testAssemblies = GetTestAssemblies();
            TestRunner runner;

            if (RegisterType.IsXUnit)
            {
                runner = new XUnitTestRunner(logger);
            }
            else
            {
                runner = new NUnitTestRunner(logger);
            }

            runner.Run(testAssemblies.ToList());

            using (var writer = new StreamWriter(options.ResultFile)) {
                runner.WriteResultsToFile(writer);
            }
            logger.Info($"Xml result can be found {options.ResultFile}");

            logger.Info($"Tests run: {runner.TotalTests} Passed: {runner.PassedTests} Inconclusive: {runner.InconclusiveTests} Failed: {runner.FailedTests} Ignored: {runner.SkippedTests}");
            return(runner.FailedTests != 0 ? 1 : 0);
        }
        void CreateNUnitTestRunner()
        {
            selectedTests = SelectedTestsHelper.CreateSelectedTestMember();
            context       = new MockNUnitTestRunnerContext();
            FileUtility.ApplicationRootPath = @"C:\SharpDevelop";

            testRunner = context.CreateNUnitTestRunner();
        }
        public void SetUp()
        {
            _bus            = MockRepository.GenerateMock <IMessageBus>();
            _configuration  = MockRepository.GenerateMock <IConfiguration>();
            _assemblyReader = MockRepository.GenerateMock <IAssemblyPropertyReader>();
            _fsService      = MockRepository.GenerateMock <IFileSystemService>();

            _runner = new NUnitTestRunner(_bus, _configuration, _assemblyReader, _fsService);
        }
Beispiel #8
0
        public static async Task Main(string[] args)
        {
            var command = new RootCommand(".NET test runner for Taurus")
            {
                NUnitTestRunner.GetNUnitCommand(),
                XUnitTestRunner.GetNUnitCommand()
            };

            await command.InvokeAsync(args);
        }
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var           options = ApplicationOptions.Current;
            TcpTextWriter writer  = null;

            if (!string.IsNullOrEmpty(options.HostName))
            {
                writer = new TcpTextWriter(options.HostName, options.HostPort);
            }

            // we generate the logs in two different ways depending if the generate xml flag was
            // provided. If it was, we will write the xml file to the tcp writer if present, else
            // we will write the normal console output using the LogWriter
            var logger = (writer == null || options.EnableXml) ? new LogWriter() : new LogWriter(writer);

            logger.MinimumLogLevel = MinimumLogLevel.Info;
            var testAssemblies = GetTestAssemblies();

            Xamarin.iOS.UnitTests.TestRunner runner;
            if (RegisterType.IsXUnit)
            {
                runner = new XUnitTestRunner(logger);
            }
            else
            {
                runner = new NUnitTestRunner(logger);
            }

            var skippedTests = await IgnoreFileParser.ParseContentFilesAsync(NSBundle.MainBundle.BundlePath);

            if (skippedTests.Any())
            {
                // ensure that we skip those tests that have been passed via the ignore files
                runner.SkipTests(skippedTests);
            }

            runner.Run((IList <TestAssemblyInfo>)testAssemblies);
            if (options.EnableXml)
            {
                runner.WriteResultsToFile(writer);
                logger.Info("Xml file was written to the tcp listener.");
            }
            else
            {
                string resultsFilePath = runner.WriteResultsToFile();
                logger.Info($"Xml result can be found {resultsFilePath}");
            }

            logger.Info($"Tests run: {runner.TotalTests} Passed: {runner.PassedTests} Inconclusive: {runner.InconclusiveTests} Failed: {runner.FailedTests} Ignored: {runner.SkippedTests}");
            if (options.TerminateAfterExecution)
            {
                TerminateWithSuccess();
            }
        }
        public ITestRunner CreateTestRunner()
        {
            TestProcessRunnerBaseContext context = new TestProcessRunnerBaseContext(processRunner,
                                                                                    testResultsMonitor,
                                                                                    fileService,
                                                                                    messageService);
            NUnitTestRunner testRunner = new NUnitTestRunner(context, options);

            testRunnersCreated.Add(testRunner);
            return(testRunner);
        }
        protected override void ConfigureFilters(NUnitTestRunner runner)
        {
            HashSet <string> excludedTestNames = null;

            using (var s = typeof(NUnitInstrumentation).Assembly.GetManifestResourceStream("nunit-excluded-tests.txt")) {
                using (var sr = new StreamReader(s, Encoding.UTF8)) {
                    excludedTestNames = LoadExcludedTests(sr);
                }
            }

            ExcludedTestNames = excludedTestNames;

            base.ConfigureFilters(runner);
        }
        public void Init()
        {
            context         = new MockRunTestCommandContext();
            processRunner   = new MockProcessRunner();
            debuggerService = new MockDebuggerService();

            testFramework = new MockNUnitTestFramework(debuggerService,
                                                       processRunner,
                                                       context.MockTestResultsMonitor,
                                                       context.UnitTestingOptions,
                                                       context.MessageService);

            testRunner   = testFramework.CreateTestRunner() as NUnitTestRunner;
            testDebugger = testFramework.CreateTestDebugger() as NUnitTestDebugger;
        }
Beispiel #13
0
    public void RunTests()
    {
        var runner = new NUnitTestRunner(
            this,
            "Release"
            );

        var dir = CurrentDirectory
                  + Path.DirectorySeparatorChar
                  + "bin"
                  + Path.DirectorySeparatorChar
                  + "Release";

        runner.RunTestsInDirectory(dir);
    }
Beispiel #14
0
        private static void Main(string[] args)
        {
//            if (args.Length == 0)
//                args = new string[] {"excluded=MANUAL"};
            // NUnitTestRunner.Run(loc, args);
            if (args.Length >= 1)
            {
                string loc = Assembly.GetExecutingAssembly().Location;
                NUnitTestRunner.Run(loc, args);
            }
            else
            {
                // QuartzTester.TestExecute
                new QuartzTester().TestExecute();
            }
        }
Beispiel #15
0
        public void CopyDependencies_CopiesAllNecessaryFiles()
        {
            if (Directory.Exists(_directory))
            {
                Directory.Delete(_directory, true);
            }

            Directory.CreateDirectory(_directory);

            var testRunner = new NUnitTestRunner();

            testRunner.CopyDependencies(_directory);

            Assert.True(File.Exists(Path.Combine(_directory, "nunit.framework.dll")));
            Assert.True(File.Exists(Path.Combine(_directory, "nunit.core.dll")));
            Assert.True(File.Exists(Path.Combine(_directory, "nunit.core.interfaces.dll")));
        }
Beispiel #16
0
        public TestService()
        {
            _clientSessions   = new Dictionary <string, string>();
            _sessionCallbacks = new Dictionary <string, ITestServiceCallback>();
            _testRunners      = new Dictionary <TestType, ITestRunner>();

            // Add the default test runners. This section could be done using MEF in the future
            var nunitTestRunner = new NUnitTestRunner();

            nunitTestRunner.TestFinished             += nunitTestRunner_TestFinished;
            nunitTestRunner.TestOutput               += nunitTestRunner_testOutput;
            nunitTestRunner.TestRunFinished          += nunitTestRunner_TestRunFinished;
            nunitTestRunner.TestRunStarted           += nunitTestRunner_TestRunStarted;
            nunitTestRunner.TestStarted              += nunitTestRunner_TestStarted;
            nunitTestRunner.UnhandledExceptionInTest += nunitTestRunner_UnhandledExceptionInTest;
            _testRunners.Add(TestType.NUnit, nunitTestRunner);
        }
Beispiel #17
0
        [PersistanceScope] // Data created when starting a test should persist!
        public void RunTestInEngine(TWEngine engine, NUnitTest test)
        {
            var oldContext = EngineFactory.Instance;

            EngineFactory.Instance = new TWEngineContext(engine);

            //TW.Graphics.Form.Hide();

            var runner = new NUnitTestRunner();

            //TODO: runner.Timeout = 10000;
            runner.RunInThisThread(test);

            DI.Get <TestSceneBuilder>().EnsureTestSceneLoaded();

            //TW.Graphics.Form.Show();

            EngineFactory.Instance = oldContext;
        }
Beispiel #18
0
        private static void Main(string[] args)
        {
            string loc = Assembly.GetExecutingAssembly().Location;

            NUnitTestRunner.Run(loc, args);
        }
Beispiel #19
0
        public void Test_RunTests()
        {
            var script = GetDummyScript();

            var grabber = new FilesGrabber(
                script.OriginalDirectory,
                script.CurrentDirectory
                );

            grabber.GrabOriginalFiles();

            CreateDummyTest();

            // Create another dummy script with a temporary directory as the original directory. This avoids having the dummy results being output
            // to the real original directory
            var script2 = GetDummyScript();

            script2.OriginalDirectory = script2.GetTmpDir();

            var runner = new NUnitTestRunner(
                script2,
                "Release"
                );

            var binDir = WorkingDirectory
                         + Path.DirectorySeparatorChar
                         + "bin"
                         + Path.DirectorySeparatorChar
                         + "Release";

            runner.RunTestsInDirectory(binDir, "SoftwareMonkeys.csAnt.Tests.CustomTestFixture");

            var htmlFileNamer = new HtmlResultFileNamer();

            var xmlFileNamer = new XmlResultFileNamer();

            var htmlResultsDir = htmlFileNamer.GetResultsDirectory(script2);

            var xmlResultsDir = xmlFileNamer.GetResultsDirectory(script2);

            Console.WriteLine("Xml results dir:");
            Console.WriteLine(xmlResultsDir);
            Console.WriteLine("Html results dir:");
            Console.WriteLine(htmlResultsDir);

            Assert.IsTrue(Directory.Exists(xmlResultsDir), "The xml results dir wasn't found.");

            Assert.IsTrue(Directory.Exists(htmlResultsDir), "The html results dir wasn't found.");

            Assert.AreEqual(1, Directory.GetFiles(xmlResultsDir).Length, "Wrong number of files found in xml results dir.");

            Assert.AreEqual(2, Directory.GetFiles(htmlResultsDir).Length, "Wrong number of files found in html results dir.");

            var finalHtmlResultsDir = htmlFileNamer.GetResultsReturnDirectory(script2);

            var finalXmlResultsDir = xmlFileNamer.GetResultsReturnDirectory(script2);

            Console.WriteLine("Final xml results dir:");
            Console.WriteLine(finalXmlResultsDir);
            Console.WriteLine("Final html results dir:");
            Console.WriteLine(finalHtmlResultsDir);

            Assert.IsTrue(Directory.Exists(finalXmlResultsDir), "The final xml results dir wasn't found.");

            Assert.IsTrue(Directory.Exists(finalHtmlResultsDir), "The final html results dir wasn't found.");

            Assert.AreEqual(1, Directory.GetFiles(finalXmlResultsDir).Length, "Wrong number of files found in final xml results dir.");

            Assert.AreEqual(2, Directory.GetFiles(finalHtmlResultsDir).Length, "Wrong number of files found in final html results dir.");
        }
Beispiel #20
0
        public void State_DefaultValueIsIdle()
        {
            var testRunner = new NUnitTestRunner();

            Assert.AreEqual(TestRunnerState.Idle, testRunner.State);
        }
Beispiel #21
0
        public void CopyDependencies_NullOutputDirectory_ThrowsException()
        {
            var testRunner = new NUnitTestRunner();

            Assert.Throws <ArgumentException>(() => testRunner.CopyDependencies(null));
        }
Beispiel #22
0
 public static void Main(string [] args)
 {
     NUnitTestRunner.PreloadAssemblies();
     server = new RemoteProcessServer();
     server.Connect(args, new RemoteNUnitTestRunner(server));
 }