/// <summary> /// Parses the specified project. /// </summary> /// <param name="project">The project.</param> /// <param name="request">The request.</param> /// <returns></returns> public IList<TestUnitWithMetadata> Get(TestProject project, TestRunRequest request) { initializer.Initialize(); var projectFileNameOnly = Path.GetFileName(request.TestRun.NUnitParameters.AssembliesToTest[0]); var projectFileNameMapped = Path.Combine(project.Path, projectFileNameOnly); var package = GetTestPackage(projectFileNameMapped, request.TestRun.NUnitParameters); package.AutoBinPath = false; package.PrivateBinPath = NUnit.Util.DomainManager.GetPrivateBinPath( parameters.RootFolder ?? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), new ArrayList(request.TestRun.NUnitParameters.AssembliesToTest) { Assembly.GetExecutingAssembly().Location }); package.BasePath = parameters.RootFolder; var domainManager = new NUnit.Util.DomainManager(); // A separate domain is used to free the assemblies after tests retrieval var domain = domainManager.CreateDomain(package); try { DomainManager.AddResolverForPaths(domain, DomainManager.GetNUnitFolders(parameters)); var testsRetrieverType = typeof (InAnotherDomainTestsRetriever); var testsRetriever = (InAnotherDomainTestsRetriever) domain.CreateInstanceAndUnwrap(testsRetrieverType.Assembly.FullName, testsRetrieverType.FullName); return testsRetriever.Get(package, request.TestRun); } finally { DomainManager.UnloadDomain(domain); } }
public void Init() { retriever = new TestsRetriever(new NUnitInitializer(), new BootstrapperParameters(), new ConsoleLog()); string targetAssembly = typeof(TestFixtureWithCategoriesOnTests).Assembly.Location; project = new TestProject(Path.GetDirectoryName(targetAssembly)); request = new TestRunRequest(new TestRun { NUnitParameters = new NUnitParameters() }); request.TestRun.NUnitParameters.AssembliesToTest.Add(targetAssembly); }
/// <summary> /// Gets the project retrieval failure. /// </summary> /// <param name="test">The test.</param> /// <param name="exception">The exception.</param> /// <returns></returns> public static TestResult GetProjectRetrievalFailure(TestRunRequest test, Exception exception = null) { return GetResultForProject(test.TestRun, exception, TestResultType.ProjectRetrievalFailure); }
/// <summary> /// Gets the no available test failure. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public static TestResult GetNoAvailableTestFailure(TestRunRequest request) { return GetResultForProject(request.TestRun, null, TestResultType.NoTests); }
/// <summary> /// Gets the unhandled exception failure. /// </summary> /// <param name="request"></param> /// <param name="exception">The exception.</param> /// <returns></returns> public static TestResult GetUnhandledExceptionFailure(TestRunRequest request, Exception exception) { return GetResultForProject(request.TestRun, exception, TestResultType.Unhandled); }
/// <summary> /// Processes the request. /// </summary> /// <param name="request">The request.</param> private void ProcessRequest(TestRunRequest request) { TestProject project; try { log.BeginActivity(string.Format("Starting executing project request {0}", request.TestRun.Id)); project = projects.Get(request.TestRun); } catch (Exception ex) { log.Error("Unable to get test project", ex); Complete(TestResultFactory.GetProjectRetrievalFailure(request, ex), request.TestRun); return; } if (project == null) { log.Error("Unable to get test project"); Complete(TestResultFactory.GetProjectRetrievalFailure(request), request.TestRun); return; } try { log.BeginActivity(string.Format("Starting parsing project request into test units {0}", request.TestRun.Id)); var testUnits = testsRetriever.Get(project, request); if (testUnits != null && testUnits.Count == 0) { log.Warning(string.Format("No tests were found in request: {0}", request.TestRun.Id)); Complete(TestResultFactory.GetNoAvailableTestFailure(request), request.TestRun); return; } // request.ConfigurationSetup = configurationOperator.ReadConfigurationSetup(project, request.TestRun.NUnitParameters); log.Info(string.Format("There were {0} tests found in {1}", testUnits != null ? testUnits.Count : 0, request.TestRun)); tests.AddRange(testUnits); request.Statistics.Initialize(testUnits != null ? testUnits.Count : 0); log.EndActivity("Finished parsing project into separate test units"); } catch (Exception ex) { log.Error("Error while parsing test request", ex); Complete(TestResultFactory.GetUnhandledExceptionFailure(request, ex), request.TestRun); } }