当前位置: 首页>>代码示例>>C#>>正文


C# Core.TestPackage类代码示例

本文整理汇总了C#中NUnit.Core.TestPackage的典型用法代码示例。如果您正苦于以下问题:C# TestPackage类的具体用法?C# TestPackage怎么用?C# TestPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestPackage类属于NUnit.Core命名空间,在下文中一共展示了TestPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

		public override bool Load(TestPackage package)
		{
			log.Info("Loading Test Package " + package.Name );

			// Initialize ExtensionHost if not already done
			if ( !CoreExtensions.Host.Initialized )
				CoreExtensions.Host.InitializeService();

			// Delayed creation of downstream runner allows us to
			// use a different runner type based on the package
			bool useThreadedRunner = package.GetSetting( "UseThreadedRunner", true );
			
			TestRunner runner = new SimpleTestRunner( this.runnerID );
            if (useThreadedRunner)
            {
                ApartmentState apartmentState = (ApartmentState)package.GetSetting("ApartmentState", ApartmentState.Unknown);
                ThreadPriority priority = (ThreadPriority)package.GetSetting("ThreadPriority", ThreadPriority.Normal);
                runner = new ThreadedTestRunner(runner, apartmentState, priority);
            }

			this.TestRunner = runner;

			if( base.Load (package) )
			{
				log.Info("Loaded package successfully" );
				return true;
			}
			else
			{
				log.Info("Package load failed" );
				return false;
			}
		}
开发者ID:Buildstarted,项目名称:ContinuousTests,代码行数:33,代码来源:RemoteTestRunner.cs

示例2: RunAsync

		public static void RunAsync (string[] args)
		{
			Paths.SetStandardWorkingDirectory ();
			File.WriteAllText ("status.txt", "running");

			var runOptions = RunOptions.Parse (args);

			if (runOptions.ShouldShowHelp) {
				runOptions.ShowHelp ();
				return;
			}

			CoreExtensions.Host.InitializeService ();

			var assembly = Assembly.GetExecutingAssembly ();

			var runner = new ThreadedTestRunner(new SimpleTestRunner());
			TestPackage package = new TestPackage (assembly.GetName ().Name);
			package.Assemblies.Add (assembly.Location);
			if (!runner.Load (package)) {
				Console.WriteLine ("Could not find the tests.");
				return;
			}

			var listener = new MobileListener (runOptions);
			var filter = new AggregateTestFilter (runOptions.Filters);
			runner.BeginRun (listener, filter, false, LoggingThreshold.Warn);
		}
开发者ID:GhostTap,项目名称:MonoGame,代码行数:28,代码来源:MobileInterface.cs

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
      // Initialise data table to hold test results
      _results.Columns.Add("test");
      _results.Columns.Add("result");
      _results.Columns.Add("time");
      _results.Columns.Add("message");
      _results.Columns.Add("class");

      // Initialise controls
      lblResult.Text = "";
      ltlStats.Text = "";

      // Initialise NUnit
      CoreExtensions.Host.InitializeService();

      // Find tests in current assembly
      _testPackage = new TestPackage(Assembly.GetExecutingAssembly().Location);

      if (!IsPostBack)
      {
        var testSuite = new TestSuiteBuilder().Build(_testPackage);
        var categoryManager = new CategoryManager();
        categoryManager.AddAllCategories(testSuite);

        cblCategories.DataSource = (from string cat in categoryManager.Categories select cat).OrderBy(x => x);
        cblCategories.DataBind();
      }
    }
开发者ID:KerwinMa,项目名称:revolver,代码行数:29,代码来源:Test.aspx.cs

示例4: LoadTests

        public ITest LoadTests(IEnumerable<string> assemblies)
        {

          
                var testRunner = new SimpleTestRunner();
                
                var enumerable = assemblies as IList<string> ?? assemblies.ToList();
                _log.Debug("Creating NUnit package for files " + string.Join(", ", enumerable));
                var package = new TestPackage("", enumerable.ToList());
                package.Settings["RuntimeFramework"] = new RuntimeFramework(RuntimeType.Net, Environment.Version);
                package.Settings["UseThreadedRunner"] = false;

//                lock (this)
//                {
                    _log.Debug("Loading NUnit package: " + package);
                    bool load = testRunner.Load(package);
                    if (!load)
                    {
                        throw new Exception("Tests load result: false.");
                    }
                    var t = testRunner.Test;
                    testRunner.Unload();
                    return t;
//                }
               
            

        }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:28,代码来源:NUnitWrapper.cs

示例5: RunAllAcceptanceTests

        public void RunAllAcceptanceTests()
        {
            //Define the name of itself
            var assemblyName = @"NBi.Testing.dll";

            //Instantiate a SimpleTestRunner
            CoreExtensions.Host.InitializeService();
            SimpleTestRunner runner = new SimpleTestRunner();

            //Define the test package as all the tests of this assembly in the class RuntimeOverrider
            //The assembly (and so the tests) will be filtered based on TestName
            TestPackage package = new TestPackage( "Test");
            package.TestName = "NBi.Testing.Acceptance.RuntimeOverrider"; //Filter
            package.Assemblies.Add(assemblyName);

            //Load the tests from the filtered package (so we don't need to filter again!)
            if( runner.Load(package) )
            {
                //Run all the tests (Have I said I've previsously filtered ? ... No seriously you read this kind of comment?)
                TestResult result = runner.Run( new NullListener(), TestFilter.Empty, false, LoggingThreshold.Off );
                //Ensure the acceptance test suite is fully positive!
                Assert.That(result.IsSuccess, Is.True);
            }
            else
                Assert.Fail("Unable to load the TestPackage from assembly '{0}'", assemblyName);
        }
开发者ID:zyh329,项目名称:nbi,代码行数:26,代码来源:TestSuiteRunner.cs

示例6: Page_Load

		protected void Page_Load(object sender, EventArgs e)
		{
			// Initialise data table to hold test results
			m_results.Columns.Add("test");
			m_results.Columns.Add("result");
            m_results.Columns.Add("time");
			m_results.Columns.Add("message");
			m_results.Columns.Add("class");

			// Initialise controls
			lblResult.Text = "";
			ltlStats.Text = "";

			// Initialise NUnit
			CoreExtensions.Host.InitializeService();

			// Find tests in current assembly
			TestPackage package = new TestPackage(Assembly.GetExecutingAssembly().Location);
			m_testSuite = new TestSuiteBuilder().Build(package);

			if (!IsPostBack)
			{
				// Display category filters
				StringCollection coll = new StringCollection();
				GetCategories((TestSuite)m_testSuite, coll);
				string[] cats = new string[coll.Count];
				coll.CopyTo(cats, 0);
				Array.Sort(cats);
				cblCategories.DataSource = cats;
				cblCategories.DataBind();
			}
		}
开发者ID:KerwinMa,项目名称:WeBlog,代码行数:32,代码来源:Test.aspx.cs

示例7: Load

		public override bool Load( TestPackage package )
		{
			Unload();

            log.Info("Loading " + package.Name);
			try
			{
				if ( this.domain == null )
					this.domain = Services.DomainManager.CreateDomain( package );

                if (this.agent == null)
                {
                    this.agent = DomainAgent.CreateInstance(domain);
                    this.agent.Start();
                }
            
				if ( this.TestRunner == null )
					this.TestRunner = this.agent.CreateRunner( this.ID );

                log.Info(
                    "Loading tests in AppDomain, see {0}_{1}.log", 
                    domain.FriendlyName, 
                    Process.GetCurrentProcess().Id);

				return TestRunner.Load( package );
			}
			catch
			{
                log.Error("Load failure");
				Unload();
				throw;
			}
		}
开发者ID:Vernathic,项目名称:ic-AutoTest.NET4CTDD,代码行数:33,代码来源:TestDomain.cs

示例8: LoadFixture

		public void LoadFixture()
		{
			TestPackage package = new TestPackage( testsDll );
			package.TestName = "NUnit.Core.Tests.SuiteBuilderTests";
			Test suite= builder.Build( package );
			Assert.IsNotNull(suite, "Unable to build suite");
		}
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:7,代码来源:SuiteBuilderTests.cs

示例9: DiscoverSuite

 public void DiscoverSuite()
 {
     TestPackage package = new TestPackage( testData );
     package.TestName = "NUnit.TestData.SuiteBuilderTests.Suite";
     Test suite = builder.Build( package );
     Assert.IsNotNull(suite, "Could not discover suite attribute");
 }
开发者ID:caleb-vear,项目名称:shouldly,代码行数:7,代码来源:SuiteBuilderTests.cs

示例10: Load

		public override bool Load(TestPackage package)
		{
			log.Info("Loading Test Package " + package.Name );

			// Initialize ExtensionHost if not already done
			if ( !CoreExtensions.Host.Initialized )
				CoreExtensions.Host.InitializeService();

			// Delayed creation of downstream runner allows us to
			// use a different runner type based on the package
			bool useThreadedRunner = package.GetSetting( "UseThreadedRunner", true );
			
			TestRunner runner = new SimpleTestRunner( this.runnerID );
			if ( useThreadedRunner )
				runner = new ThreadedTestRunner( runner );

			this.TestRunner = runner;

			if( base.Load (package) )
			{
				log.Info("Loaded package successfully" );
				return true;
			}
			else
			{
				log.Info("Package load failed" );
				return false;
			}
		}
开发者ID:cdromka,项目名称:sonar-csharp,代码行数:29,代码来源:RemoteTestRunner.cs

示例11: Load

        public override bool Load( TestPackage package )
        {
            Unload();

            try
            {
                if ( domain == null )
                {
                    domain = DomainManager.CreateDomain( package );
                }

                if ( agent == null )
                {
                    agent = DomainAgent.CreateInstance( domain );
                    agent.Start();
                }

                if ( TestRunner == null )
                {
                    TestRunner = agent.CreateRunner( ID );
                }

                return TestRunner.Load( package );
            }
            catch
            {
                Unload();
                throw;
            }
        }
开发者ID:idavis,项目名称:Giles,代码行数:30,代码来源:DomainRunner.cs

示例12: RunAllTests

        /// <summary>
        /// Runs all tests</summary>
        /// <param name="displayName">Name of the test, which is normally the executing
        /// assembly's Location.</param>
        /// <param name="assemblyPaths">List of assemblies to actually test</param>
        /// <returns>0 if tests ran successfully, a negative number otherwise</returns>
        public static int RunAllTests(string displayName, List<string> assemblyPaths)
        {
            TestRunner runner;
            try
            {
                var package = new TestPackage(displayName, assemblyPaths);
                runner = new DefaultTestRunnerFactory().MakeTestRunner(package);
                runner.Load(package);
            }
            catch (System.IO.FileLoadException)
            {
                // likely caused by ATF source zip file downloaded from internet without unblocking it
                Console.WriteLine("NUnit failed to load {0}", displayName);
                Console.WriteLine(@"Possibly need to unblock the downloaded ATF source zip file before unzipping");
                Console.WriteLine(@"(right click on the zip file -> Properties -> Unblock)");
                return -3;
            }
            catch (Exception)
            {
                return -2;

            }
            
            runner.Run(new UnitTestListener());

            if (runner.TestResult.IsFailure)
                return -1;

            return 0;
        }
开发者ID:sbambach,项目名称:ATF,代码行数:36,代码来源:Program.cs

示例13: Load

		public override bool Load(TestPackage package)
		{
            log.Info("Loading " + package.Name);
			Unload();

            RuntimeFramework runtimeFramework = package.Settings["RuntimeFramework"] as RuntimeFramework;
            if ( runtimeFramework == null )
                 runtimeFramework = RuntimeFramework.CurrentFramework;

            bool loaded = false;

			try
			{
				if (this.agent == null)
					this.agent = Services.TestAgency.GetAgent( 
						runtimeFramework, 
						20000 );
		
				if (this.agent == null)
					return false;
	
				if ( this.TestRunner == null )
					this.TestRunner = agent.CreateRunner(this.runnerID);

				loaded = base.Load (package);
                return loaded;
			}
			finally
			{
                // Clean up if the load failed
				if ( !loaded ) Unload();
			}
		}
开发者ID:Phaiax,项目名称:dotnetautoupdate,代码行数:33,代码来源:ProcessRunner.cs

示例14: Main

        public static void Main()
        {
            // Set common application locale, check 'app.config' for this property
            SetLocale(ConfigurationManager.AppSettings["Locale"]);

            // Get test data from scenario file
            Scenario scenario = GetScenario(ConfigurationManager.AppSettings["Nunit.Runner.Scenario"]);
            string suite = scenario.Name;
            IList<string> testClasses = scenario.Tests;

            // Start tests
            CoreExtensions.Host.InitializeService();
            SimpleTestRunner runner = new SimpleTestRunner();
            TestPackage package = new TestPackage(suite);
            string loc = Assembly.GetExecutingAssembly().Location;
            package.Assemblies.Add(loc);
            try
            {
                if (runner.Load(package))
                {
                    TestResult result = runner.Run(new RunnerListener(), new ClassTestFilter(testClasses), true, LoggingThreshold.Debug);
                }
            }
            catch (Exception e)
            {
                _log.Error(e.Message, e);
            }
        }
开发者ID:kool79,项目名称:htmlelements-dotnet,代码行数:28,代码来源:Runner.cs

示例15: LoadAssemblyWithSuite

		public void LoadAssemblyWithSuite()
		{
			TestPackage package = new TestPackage( mockDll );
			package.TestName = "NUnit.Tests.Assemblies.MockSuite";
			runner.Load( package );
			Assert.IsNotNull(runner.Test, "Unable to build suite");
		}
开发者ID:Phaiax,项目名称:dotnetautoupdate,代码行数:7,代码来源:BasicRunnerTests.cs


注:本文中的NUnit.Core.TestPackage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。