public static void BuildFromReturnsImpliedFixture() { var suite = new DefaultSuiteBuilder().BuildFrom(new TypeWrapper(typeof(ImpliedFixture))) as TestFixture; Assert.NotNull(suite, "No test fixture was built"); Assert.That(suite.Name, Is.EqualTo(nameof(ImpliedFixture))); }
private TestSuite GetTestSuite() { var suiteBuilder = new DefaultSuiteBuilder(); var testSuite = suiteBuilder.BuildFrom(new TypeWrapper(typeof(TFixture))); testSuite.Fixture = _fixture; return(testSuite); }
public void NotRunnableWhenIMethodInfoAbstractionReturnsMultipleIRepeatTestAttributes() { var fixtureSuite = new DefaultSuiteBuilder().BuildFrom(new CustomTypeWrapper( new TypeWrapper(typeof(FixtureWithMultipleRepeatAttributesOnSameMethod)), extraMethodAttributes: new Attribute[] { new CustomRepeatAttribute(), new RepeatAttribute(2) })); var method = fixtureSuite.Tests.Single(); Assert.That(method.RunState, Is.EqualTo(RunState.NotRunnable)); Assert.That(method.Properties.Get(PropertyNames.SkipReason), Is.EqualTo("Multiple attributes that repeat a test may cause issues.")); }
public void IRepeatTestAttributeIsEffectiveWhenAddedThroughIMethodInfoAbstraction() { var fixtureSuite = new DefaultSuiteBuilder().BuildFrom(new CustomTypeWrapper( new TypeWrapper(typeof(FixtureWithMultipleRepeatAttributesOnSameMethod)), extraMethodAttributes: new Attribute[] { new RepeatAttribute(2) })); var fixtureInstance = new FixtureWithMultipleRepeatAttributesOnSameMethod(); fixtureSuite.Fixture = fixtureInstance; TestBuilder.RunTest(fixtureSuite, fixtureInstance); Assert.That(fixtureInstance.MethodRepeatCount, Is.EqualTo(2)); }
public static TestSuite MakeFixture(List <Type> types) { // following the pattern found in DefaultTestAssemblyBuilder var fixtures = new List <Test>(); var defaultSuiteBuilder = new DefaultSuiteBuilder(); foreach (var type in types) { var typeInfo = new TypeWrapper(type); var test = defaultSuiteBuilder.BuildFrom(typeInfo); fixtures.Add(test); } var assembly = AssemblyHelper.Load("nunit.testdata"); var assemblyPath = AssemblyHelper.GetAssemblyPath(assembly); TestSuite testSuite = new TestAssembly(assembly, assemblyPath); var treeBuilder = new NamespaceTreeBuilder(testSuite); treeBuilder.Add(fixtures); return(treeBuilder.RootSuite); }