Beispiel #1
0
 /// <summary>Called when the whole test suite has started.</summary>
 public void StartTestSuite(NUnitTestData suite)
 {
     if (Verbose)
     {
         Console.WriteLine(Prefix + "------------------------------------------");
     }
 }
Beispiel #2
0
 /// <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;
 }
Beispiel #3
0
 /// <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 );
 }
Beispiel #4
0
        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);
        }
Beispiel #6
0
 /// <summary>Called when the whole test suite has started.</summary>
 public void StartTestSuite(NUnitTestData suite) {
     if (Verbose) {
         Console.WriteLine(Prefix + "------------------------------------------");
     }
 }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
        // 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;
        }
Beispiel #9
0
 /// <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);
 }
Beispiel #10
0
 /// <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;
 }
Beispiel #11
0
 /// <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);
 }
Beispiel #12
0
 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;
 }
Beispiel #13
0
 /// <summary>Called when the whole test suite has started.</summary>
 public void StartTestSuite(NUnitTestData suite)
 {
 }
Beispiel #14
0
 /// <summary>Called when the whole test suite has started.</summary>
 public void StartTestSuite(NUnitTestData suite)
 {
 }