Ejemplo n.º 1
0
 public TestResultBuilder(TestContext testContext, IDotNetCoreTestProvider rootTest)
 {
     this.testContext  = testContext;
     this.rootTest     = rootTest;
     runningSingleTest = rootTest is DotNetCoreUnitTest;
     TestResult        = UnitTestResult.CreateSuccess();
 }
Ejemplo n.º 2
0
        public void DebugTests(
            TestContext testContext,
            IDotNetCoreTestProvider testProvider,
            string testAssemblyPath)
        {
            try {
                IsRunningTests   = true;
                this.testContext = testContext;

                EnsureStarted();

                testResultBuilder = new TestResultBuilder(testContext, testProvider);

                var tests = testProvider.GetTests();
                if (tests == null)
                {
                    GetProcessStartInfo(new [] { testAssemblyPath });
                }
                else
                {
                    GetProcessStartInfo(tests);
                }
            } catch (Exception ex) {
                this.testContext = null;

                testContext.Monitor.ReportRuntimeError(
                    GettextCatalog.GetString("Failed to start debug tests."),
                    ex);

                if (testResultBuilder != null)
                {
                    testResultBuilder.CreateFailure(ex);
                }

                IsRunningTests = false;
            }
        }
Ejemplo n.º 3
0
        UnitTestResult RunTest(
            TestContext testContext,
            IDotNetCoreTestProvider testProvider,
            string testAssemblyPath)
        {
            if (testPlatformAdapter.HasDiscoveryFailed)
            {
                return(ReportLoadError(testContext));
            }

            if (!File.Exists(testAssemblyPath))
            {
                return(HandleMissingAssemblyOnRun(testContext, testAssemblyPath));
            }

            if (testContext.ExecutionContext.ExecutionHandler == null)
            {
                testPlatformAdapter.RunTests(testContext, testProvider, testAssemblyPath);
            }
            else
            {
                testPlatformAdapter.DebugTests(testContext, testProvider, testAssemblyPath);
            }

            while (testPlatformAdapter.IsRunningTests)
            {
                if (testContext.Monitor.CancellationToken.IsCancellationRequested)
                {
                    testPlatformAdapter.CancelTestRun();
                    break;
                }

                Thread.Sleep(100);
            }
            Status = TestStatus.Ready;
            return(testPlatformAdapter.TestResult);
        }
Ejemplo n.º 4
0
 public UnitTestResult RunTest(TestContext testContext, IDotNetCoreTestProvider testProvider)
 {
     return(RunTest(testContext, testProvider, GetAssemblyFileName()));
 }