Esempio n. 1
0
        private void AddFixture(TestAssembly testAssembly, IFixture fixture)
        {
            List<ITestCase> tests = new List<ITestCase>();

            System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                foreach (ITestCase test in fixture.CreateTestCases())
                {
                    if (test == null)
                        continue;
                    if (!testCaseFilter.Filter(fixture,test))
                        continue;
                    ITestCase decoratedTest = DecorateTest(fixture, test);
                    tests.Add(decoratedTest);
                }
                testAssembly.AddFixture(fixture, tests);
            }
            catch (Exception ex)
            {
                BadFixture badFixture = new BadFixture(fixture.Name, ex);
                tests.Clear();
                testAssembly.AddFixture(badFixture, tests);
            }
        }
Esempio n. 2
0
        public TestAssembly CreateTestAssembly(Assembly assembly)
        {
            if (assembly == null)
                throw new ArgumentNullException("assembly");

            TestAssembly testAssembly = new TestAssembly(assembly);
            this.ReflectAssemblySetUpAndTearDown(testAssembly);

            foreach (Type type in assembly.GetExportedTypes())
            {
                if (type.IsAbstract || type.IsInterface)
                    continue;
                foreach (IFixture fixture in this.ReflectFixtures(type))
                    AddFixture(testAssembly, fixture);
            }

            return testAssembly;
        }
Esempio n. 3
0
        private void ReflectAssemblySetUpAndTearDown(TestAssembly testAssembly)
        {
            AssemblySetUpAndTearDownAttribute assemblySetUpAndTearDown =
                ReflectionHelper.GetAttribute <AssemblySetUpAndTearDownAttribute>(testAssembly.Assembly);

            if (assemblySetUpAndTearDown != null)
            {
                testAssembly.AssemblySetUp = ReflectionHelper.GetMethod(
                    assemblySetUpAndTearDown.TargetType,
                    typeof(AssemblySetUpAttribute),
                    BindingFlags.Static | BindingFlags.Public
                    );
                testAssembly.AssemblyTearDown = ReflectionHelper.GetMethod(
                    assemblySetUpAndTearDown.TargetType,
                    typeof(AssemblyTearDownAttribute),
                    BindingFlags.Static | BindingFlags.Public
                    );
            }
        }
 public override void AfterAssembly(TestAssembly testAssembly)
 {
     base.AfterAssembly(testAssembly);
 }
 public override void BeforeAssembly(TestAssembly testAssembly)
 {
     base.BeforeAssembly(testAssembly);
     if (silent)
         return;
 }
Esempio n. 6
0
        private void ReflectAssemblySetUpAndTearDown(TestAssembly testAssembly)
        {
            AssemblySetUpAndTearDownAttribute assemblySetUpAndTearDown =
                ReflectionHelper.GetAttribute<AssemblySetUpAndTearDownAttribute>(testAssembly.Assembly);
            if (assemblySetUpAndTearDown != null)
            {
                testAssembly.AssemblySetUp = ReflectionHelper.GetMethod(
                    assemblySetUpAndTearDown.TargetType,
                    typeof(AssemblySetUpAttribute),
                    BindingFlags.Static | BindingFlags.Public
                    );
                testAssembly.AssemblyTearDown = ReflectionHelper.GetMethod(
                    assemblySetUpAndTearDown.TargetType,
                    typeof(AssemblyTearDownAttribute),
                    BindingFlags.Static | BindingFlags.Public
                    );
            }

        }
Esempio n. 7
0
 public virtual void AfterAssembly(TestAssembly testAssembly)
 {
     this.assemblyCounter = null;
 }
Esempio n. 8
0
 public virtual void BeforeAssembly(TestAssembly testAssembly)
 {
     this.assemblyCounter = new TestCounter(testAssembly.GetTestCount());
 }
Esempio n. 9
0
        private void RunAssemblyTearDown(TestAssembly testAssembly)
        {
            if (testAssembly.AssemblyTearDown == null)
                return;

            Result result = new Result(testAssembly.AssemblyTearDown.Name);
            System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                result.Start();
                testAssembly.AssemblyTearDown.Invoke(null, null);
                result.Success();
            }
            catch (Exception ex)
            {
                Exception current = ex;
                if (current is TargetInvocationException)
                    current = current.InnerException;
                if (current is QuickGraph.Unit.Exceptions.IgnoreException)
                    result.Ignore();
                else
                    result.Fail(current);
            }
            this.TestListeners.AssemblyTearDown(result);
        }
Esempio n. 10
0
        private void ExecuteTestAssembly(TestAssembly testAssembly)
        {
            this.TestListeners.BeforeAssembly(testAssembly);

            // run assemblysetup
            System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                if (this.RunAssemblySetUp(testAssembly))
                {
                    foreach (IFixture fixture in testAssembly.Fixtures)
                    {
                        using (FixtureRunner runner =
                            new FixtureRunner(
                            fixture,
                            testAssembly.GetTestCasesFromFixture(fixture),
                            this.TestListeners)
                            )
                        {
                            runner.Run();
                        }
                        // collect GC
                        GC.WaitForPendingFinalizers();
                        GC.Collect();
                    }
                }
            }
            finally
            {
                // run assembly teardown
                this.RunAssemblyTearDown(testAssembly);
                this.TestListeners.AfterAssembly(testAssembly);
            }
        }
 public void AfterAssembly(TestAssembly testAssembly)
 {
     if (this.currentTestAssembly != null)
     {
         this.currentTestAssembly.EndTime = DateTime.Now;
         this.currentTestAssembly = null;
     }
 }
 public void BeforeAssembly(TestAssembly testAssembly)
 {
     this.currentTestAssembly = new XmlTestAssembly(testAssembly.Assembly.GetName(), testAssembly.Assembly.Location);
     this.currentTestAssembly.StartTime = DateTime.Now;
     this.testBatch.TestAssemblies.Add(this.currentTestAssembly);
 }