/// <summary>Called when the whole test suite has started.</summary> public void StartTestSuite(NUnitTestData suite) { if (Verbose) { Console.WriteLine(Prefix + "------------------------------------------"); } }
/// <summary> /// Initializes a new instance of the <see cref="NUnitTestRunner"/> class. /// </summary> /// <param name="testData">The test data.</param> public NUnitTestRunner(NUnitTestData testData) { _nunittest = testData; string nunitsuite = testData.Class + "," + testData.Assembly; _suite = GetSuite(nunitsuite); testData.Suite = _suite; }
/// <summary> /// Called when the whole test suite has started. /// </summary> public void StartTestSuite(NUnitTestData suite) { XmlDeclaration decl = _document.CreateXmlDeclaration("1.0", null, null); _document.AppendChild(decl); _suiteElement = _document.CreateElement(ElementTestSuite); // // if this is a testsuite, use it's name // string suiteName = suite.Suite.ToString(); if (String.IsNullOrEmpty(suiteName)) { suiteName = "test"; } _suiteElement.SetAttribute(AttributeName, suiteName ); }
internal NUnitTestData GetTestData() { NUnitTestData data = new NUnitTestData(); data.OutFile = OutFile; data.ToDir = ToDir; data.Class = Class; data.Assembly = Assembly; data.Fork = Fork; data.HaltOnError = HaltOnError; data.HaltOnFailure = HaltOnFailure; data.AppConfigFile = AppConfigFile; return(data); }
/// <summary> /// Called when the whole test suite has started. /// </summary> public void StartTestSuite(NUnitTestData suite) { XmlDeclaration decl = _document.CreateXmlDeclaration("1.0", null, null); _document.AppendChild(decl); _suiteElement = _document.CreateElement(ElementTestSuite); // // if this is a testsuite, use it's name // string suiteName = suite.Suite.ToString(); if (String.IsNullOrEmpty(suiteName)) { suiteName = "test"; } _suiteElement.SetAttribute(AttributeName, suiteName); }
private RunnerResult ExecuteInProc(NUnitTestData test) { try { NUnitTestRunner runner = new NUnitTestRunner(test); if (runner.NeedsRunning()) { Log(Level.Info, "Running '{0}'.", test.Class); runner.Run(string.Empty, Verbose); } else { Log(Level.Info, "Skipping '{0}' because tests haven't changed.", test.Class); } return runner.ResultCode; } catch (Exception ex) { throw new BuildException("Error running unit test.", Location, ex); } }
// TODO implement launching in a seperate App Domain private RunnerResult ExecuteInAppDomain(NUnitTestData test) { // spawn new domain in specified directory AppDomainSetup domSetup = new AppDomainSetup(); domSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; domSetup.ConfigurationFile = Project.GetFullPath(test.AppConfigFile); domSetup.ApplicationName = "NAnt Remote Domain"; AppDomain newDomain = AppDomain.CreateDomain(domSetup.ApplicationName, AppDomain.CurrentDomain.Evidence, domSetup); // instantiate subclassed test runner in new domain Type runnerType = typeof(RemoteNUnitTestRunner); ObjectHandle oh = newDomain.CreateInstance ( runnerType.Assembly.FullName, runnerType.FullName, false, 0, null, new object[] { test }, null, null, null ); RemoteNUnitTestRunner runner = (RemoteNUnitTestRunner)(oh.Unwrap()); Log(Level.Info, "Running '{0}'.", test.Class); runner.Run(string.Empty, Verbose); return runner.ResultCode; }
/// <summary> /// Initializes a new instance of the <see cref="RemoteNUnitTestRunner"/> class. /// </summary> /// <param name="testData">The test data.</param> public RemoteNUnitTestRunner(NUnitTestData testData) { _runner = new NUnitTestRunner(testData); }
/// <summary> /// Returns the output file or null if does not use a file. /// </summary> protected FileInfo GetOutput(FormatterData formatterData, NUnitTestData test) { if (formatterData.UseFile) { string filename = test.OutFile + formatterData.Extension; string absFilename = Path.Combine(test.ToDir, filename); return new FileInfo(absFilename); } return null; }
/// <summary> /// Creates the formatters to be used when running this test. /// </summary> protected void CreateFormatters(NUnitTestData testData, string logPrefix, bool verbose) { // Now add the specified formatters foreach (FormatterData formatterData in testData.Formatters) { // determine file FileInfo outFile = GetOutput(formatterData, testData); IResultFormatter formatter = CreateFormatter(formatterData.Type, outFile); Formatters.Add(formatter); } // Add default formatter // The Log formatter is special in that it always writes to the // Log class rather than the TextWriter set in SetOutput(). // HACK! LogFormatter logFormatter = new LogFormatter(logPrefix, verbose); Formatters.Add(logFormatter); }
internal NUnitTestData GetTestData() { NUnitTestData data = new NUnitTestData(); data.OutFile = OutFile; data.ToDir = ToDir; data.Class = Class; data.Assembly = Assembly; data.Fork = Fork; data.HaltOnError = HaltOnError; data.HaltOnFailure = HaltOnFailure; data.AppConfigFile = AppConfigFile; return data; }
/// <summary>Called when the whole test suite has started.</summary> public void StartTestSuite(NUnitTestData suite) { }