Exemplo n.º 1
0
        private TestSuite BuildFromFixtureType(string assemblyName, Type testType)
        {
            ISuiteBuilder suiteBuilder = new NUnitTestFixtureBuilder();

            if (suiteBuilder.CanBuildFrom(testType))
            {
                return(BuildTestAssembly(assemblyName, new Test[1] {
                    suiteBuilder.BuildFrom(testType)
                }));
            }
            return(null);
        }
Exemplo n.º 2
0
        public IEnumerable <TestSuite> BuildFrom(ITypeInfo typeInfo)
        {
            var methods = typeInfo.GetMethodsWithAttribute <BehaviourAttribute>(inherit: false);

            foreach (var method in methods)
            {
                var builder = new NUnitTestFixtureBuilder();

                var fixture = builder.BuildFrom(typeInfo, new MethodFilter(method));

                fixture.FullName = $"{typeInfo.FullName}.{method.Name}";

                yield return(fixture);
            }
        }
        public IEnumerable <TestSuite> BuildFrom(ITypeInfo typeInfo)
        {
            // TODO: the name set here will still get overridden by a test case. Figure out how to
            // build on top of the test case name instead
            // This possibly implies that cases are built after the fixture methods run
            // https://groups.google.com/forum/#!topic/nunit-discuss/PT0NQaL7AMg
            NUnitTestFixtureBuilder b = new NUnitTestFixtureBuilder();
            TestSuite testSuite       = b.BuildFrom(typeInfo, new NoFilter());

            foreach (NUnit.Framework.Internal.Test t in testSuite.Tests)
            {
                t.Name = $"{_prefix}_{t.Name}";
            }
            yield return(testSuite);
        }
        private TestSuite BuildFromFixtureType(string assemblyName, Type testType)
        {
            ISuiteBuilder testFixtureBuilder = new NUnitTestFixtureBuilder();

            // TODO: This is the only situation in which we currently
            // recognize and load legacy suites. We need to determine
            // whether to allow them in more places.
            //if (legacySuiteBuilder.CanBuildFrom(testType))
            //    return (TestSuite)legacySuiteBuilder.BuildFrom(testType);
            //else
            if (testFixtureBuilder.CanBuildFrom(testType))
            {
                return(BuildTestAssembly(assemblyName,
                                         new Test[] { testFixtureBuilder.BuildFrom(testType) }));
            }
            return(null);
        }
        private IEnumerable <TestSuite> GetTestSuite(ITypeInfo typeInfo, IPreFilter filter)
        {
            InheritAttributes(typeInfo);

            foreach (var constructor in typeInfo.Type.GetConstructors())
            {
                var arguments = new List <object>();
                foreach (var parameter in constructor.GetParameters())
                {
                    var argument = Resolver.GetService(constructor, parameter.ParameterType);
                    if (argument != null)
                    {
                        arguments.Add(argument);
                    }
                }

                var fixture = new NUnitTestFixtureBuilder().BuildFrom(typeInfo, filter, new TestFixtureData(arguments.ToArray()));
                CheckApplyExecuteInSetup(fixture, constructor);

                yield return(fixture);
            }
        }
Exemplo n.º 6
0
 public void CreateBuilder()
 {
     builder = new NUnitTestFixtureBuilder();
 }