本文整理汇总了C#中NUnit.Core.TestSuiteBuilder类的典型用法代码示例。如果您正苦于以下问题:C# TestSuiteBuilder类的具体用法?C# TestSuiteBuilder怎么用?C# TestSuiteBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestSuiteBuilder类属于NUnit.Core命名空间,在下文中一共展示了TestSuiteBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
示例2: Hierarchy
public void Hierarchy()
{
TestSuiteBuilder builder = new TestSuiteBuilder();
Test suite = builder.Build( new TestPackage( testsDll ) );
suite = (Test)suite.Tests[0];
Assert.AreEqual("NUnit", suite.TestName.Name);
suite = (Test)suite.Tests[0];
Assert.AreEqual("Tests", suite.TestName.Name);
Assert.AreEqual(MockAssembly.Fixtures, suite.Tests.Count);
Test singletonSuite = TestFinder.Find("Singletons", suite, false);
Assert.AreEqual(1, singletonSuite.Tests.Count);
Test mockSuite = TestFinder.Find("Assemblies", suite, false);
Assert.AreEqual(1, mockSuite.Tests.Count);
Test mockFixtureSuite = TestFinder.Find("MockTestFixture", mockSuite, false);
Assert.AreEqual(MockTestFixture.Tests, mockFixtureSuite.Tests.Count);
foreach(Test t in mockFixtureSuite.Tests)
{
Assert.IsFalse(t.IsSuite, "Should not be a suite");
}
}
示例3: SetUp
public void SetUp()
{
TestSuiteBuilder builder = new TestSuiteBuilder();
suite = builder.Build( new TestPackage( testsDll ) );
treeView = new TestSuiteTreeView();
}
示例4: GetTestInfo
public NunitTestInfo GetTestInfo (string path, List<string> supportAssemblies)
{
InitSupportAssemblies (supportAssemblies);
TestSuite rootTS = new TestSuiteBuilder ().Build (new TestPackage (path));
return BuildTestInfo (rootTS);
}
示例5: LoadTestFixtureFromAssembly
public void LoadTestFixtureFromAssembly()
{
TestSuiteBuilder builder = new TestSuiteBuilder();
TestPackage package = new TestPackage( testsDll );
package.TestName = "NUnit.Tests.Assemblies.MockTestFixture";
Test suite= builder.Build( package );
Assert.IsNotNull(suite);
}
示例6: CanAddAllAvailableCategoriesInTestTree
public void CanAddAllAvailableCategoriesInTestTree()
{
TestSuiteBuilder builder = new TestSuiteBuilder();
Test suite = builder.Build( new TestPackage( "mock-assembly.dll" ) );
categoryManager.AddAllCategories( suite );
//Assert.AreEqual( MockAssembly.Categories, categoryManager.Categories.Count );
}
示例7: Setup
public void Setup()
{
progressBar = new TestProgressBar();
TestSuiteBuilder builder = new TestSuiteBuilder();
suite = new TestNode( builder.Build( new TestPackage( testsDll ) ) );
mockEvents = new MockTestEventSource( suite );
}
示例8: CanAddTestCategories
public void CanAddTestCategories()
{
TestSuiteBuilder builder = new TestSuiteBuilder();
Test suite = builder.Build( new TestPackage( "mock-assembly.dll" ) );
Test test = TestFinder.Find( "MockTest3", suite );
categoryManager.AddCategories( test );
Assert.AreEqual( 2, categoryManager.Categories.Count );
}
示例9: Setup
public void Setup()
{
statusBar = new StatusBar();
TestSuiteBuilder builder = new TestSuiteBuilder();
suite = builder.Build( new TestPackage( testsDll ) );
mockEvents = new MockTestEventSource( suite );
}
示例10: PrepareTestSuite
private TestSuite PrepareTestSuite(List<String> assemblyList)
{
CoreExtensions.Host.InitializeService();
var testPackage = new TestPackage("Unity",
assemblyList);
var builder = new TestSuiteBuilder();
TestExecutionContext.CurrentContext.TestPackage = testPackage;
TestSuite suite = builder.Build(testPackage);
return suite;
}
示例11: RunTestsOnAssembly
/// <summary>
/// Runs NUnit-compatible unit tests in an assembly in a debugger-friendly way.</summary>
/// <param name="assembly">
/// The assembly containing the unit tests to run.</param>
/// <param name="suppressTimesInLog">
/// Indicates whether to suppress the timing information in the log output produced. Defaults to <c>false</c>.</param>
/// <param name="filter">
/// If not <c>null</c> (the default), only tests that match this regular expression are run.</param>
public static void RunTestsOnAssembly(Assembly assembly, bool suppressTimesInLog = false, string filter = null)
{
var package = new TestPackage(assembly.Location);
if (!CoreExtensions.Host.Initialized)
CoreExtensions.Host.InitializeService();
var testsIndirect = new TestSuiteBuilder().Build(package);
var tests = directize(testsIndirect, filter);
var results = new TestResult(tests);
tests.Run(results, new DirectListener(suppressTimesInLog), TestFilter.Empty);
}
示例12: NoNamespaceInAssembly
public void NoNamespaceInAssembly()
{
TestSuiteBuilder builder = new TestSuiteBuilder();
Test suite = builder.Build( new TestPackage( nonamespaceDLL ) );
Assert.IsNotNull(suite);
Assert.AreEqual( NoNamespaceTestFixture.Tests, suite.TestCount );
suite = (TestSuite)suite.Tests[0];
Assert.IsNotNull(suite);
Assert.AreEqual( "NoNamespaceTestFixture", suite.TestName.Name );
Assert.AreEqual( "NoNamespaceTestFixture", suite.TestName.FullName );
}
示例13: RunMockTests
public void RunMockTests()
{
string testsDll = NUnit.Tests.Assemblies.MockAssembly.AssemblyPath;
TestSuiteBuilder suiteBuilder = new TestSuiteBuilder();
Test suite = suiteBuilder.Build( new TestPackage( testsDll ) );
TestResult result = suite.Run(NullListener.NULL, TestFilter.Empty);
StringBuilder builder = new StringBuilder();
new XmlResultWriter(new StringWriter(builder)).SaveTestResult(result);
string resultXml = builder.ToString();
resultDoc = new XmlDocument();
resultDoc.LoadXml(resultXml);
}
示例14: RunnerHandler
public RunnerHandler(string prefix, List<string> assemblies, string testResult)
{
this.prefix = prefix;
var codeBase = Assembly.GetExecutingAssembly().CodeBase;
var directoryName = Path.GetDirectoryName(codeBase);
if (directoryName == null) throw new DirectoryNotFoundException("Unable to determine running location for test runner");
// Ensure the assembly path exists
var currentDirectory = new Uri(directoryName).LocalPath;
assemblyList = new List<string>();
foreach (var assemblyName in assemblies)
{
var assemblypath = Path.GetFullPath(Path.Combine(currentDirectory, assemblyName + ".dll"));
if (!File.Exists(assemblypath)) throw new FileNotFoundException("Cannot find test assembly at " + assemblypath);
assemblyList.Add(assemblypath);
}
// Get the test result path
if (!string.IsNullOrEmpty(testResult))
{
testResult = testResult.Replace("$(dataFolder)", Settings.DataFolder);
testresultpath = Path.GetFullPath(Path.Combine(currentDirectory, testResult));
}
// Initialize NUnit
if (!CoreExtensions.Host.Initialized) CoreExtensions.Host.InitializeService();
package = new TestPackage(prefix, assemblyList);
var testSuite = new TestSuiteBuilder().Build(package);
// Recursively load all tests
Action<ITest> getTests = null;
getTests = x =>
x.Tests.Cast<ITest>().ToList().ForEach(t =>
{
t.Categories.Cast<string>().ToList().ForEach(c =>
{
if (!categories.Contains(c)) categories.Add(c);
});
var item = t as NUnitTestMethod;
if (item != null) tests.Add(item);
if (t.IsSuite) getTests(t);
});
getTests(testSuite);
}
示例15: RunMockTests
public void RunMockTests()
{
string testsDll = "mock-assembly.dll";
TestSuiteBuilder suiteBuilder = new TestSuiteBuilder();
Test suite = suiteBuilder.Build( new TestPackage( testsDll ) );
TestResult result = suite.Run(NullListener.NULL);
StringBuilder builder = new StringBuilder();
StringWriter writer = new StringWriter(builder);
XmlResultVisitor visitor = new XmlResultVisitor(writer, result);
result.Accept(visitor);
visitor.Write();
string resultXml = builder.ToString();
Console.WriteLine(resultXml);
resultDoc = new XmlDocument();
resultDoc.LoadXml(resultXml);
}