Пример #1
0
        public static bool ReadFixture(Type fixtureType, IAssemblyData data, string workingDirectory)
        {
            var fixtureAttribs = CustomAttributeData.GetCustomAttributes(fixtureType);

            if (!fixtureAttribs.Any(x => x.Constructor.DeclaringType.Name == "TestFixtureAttribute"))
            {
                //Console.WriteLine("Specified fixture does not have the required TestFixture attribute.");
                return false;
            }

            var fixData = new FixtureData(data, fixtureType.Name);
            data.Fixtures.Add(fixData);

            foreach (var test in fixtureType.GetMethods())
            {
                var testAttribs = CustomAttributeData.GetCustomAttributes(test);

                if (!testAttribs.Any(x => x.Constructor.DeclaringType.Name == "TestAttribute"))
                {
                    // skip this method
                    continue;
                }

                if (!ReadTest(test, fixData, workingDirectory))
                {
                    //Console.WriteLine(string.Format("Journal could not be created for test:{0} in fixture:{1}", _test,_fixture));
                    continue;
                }
            }

            // sort the collection
            fixData.Tests = fixData.Tests.Sorted(x => x.Name);

            return true;
        }
Пример #2
0
        public static bool ReadFixture(Type fixtureType, IAssemblyData data, string workingDirectory)
        {
            var fixtureAttribs = CustomAttributeData.GetCustomAttributes(fixtureType);

            if (!fixtureAttribs.Any(x => x.Constructor.DeclaringType.Name == "TestFixtureAttribute"))
            {
                //Console.WriteLine("Specified fixture does not have the required TestFixture attribute.");
                return(false);
            }

            var fixData = new FixtureData(data, fixtureType.Name);

            data.Fixtures.Add(fixData);

            foreach (var test in fixtureType.GetMethods())
            {
                var testAttribs = CustomAttributeData.GetCustomAttributes(test);

                if (!testAttribs.Any(x => x.Constructor.DeclaringType.Name == "TestAttribute"))
                {
                    // skip this method
                    continue;
                }

                if (!ReadTest(test, fixData, workingDirectory))
                {
                    //Console.WriteLine(string.Format("Journal could not be created for test:{0} in fixture:{1}", _test,_fixture));
                    continue;
                }
            }

            // sort the collection
            fixData.Tests = fixData.Tests.Sorted(x => x.Name);

            return(true);
        }
Пример #3
0
        public override IList<IAssemblyData> ReadAssembly(string assemblyPath, string workingDirectory,
            GroupingType groupType, bool isTesting)
        {
            var dummyTestPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "RunnerTests.dll");
            var assData = new AssemblyData(dummyTestPath, "RunnerTests", groupType);

            var cat1 = new CategoryData(assData, "Smoke");
            var cat2 = new CategoryData(assData, "Integration");
            var cat3 = new CategoryData(assData, "Failure");
            assData.Categories = new ObservableCollection<ITestGroup>() { cat1, cat2, cat3 };

            var fix1 = new FixtureData(assData, "FixtureA");
            var fix2 = new FixtureData(assData, "FixtureB");
            assData.Fixtures = new ObservableCollection<ITestGroup>() { fix1, fix2 };

            var testModelPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "empty.rfa");

            var test1 = new TestData(fix1, "TestA", testModelPath, false);
            var test2 = new TestData(fix1, "TestB", testModelPath, false);
            var test3 = new TestData(fix1, "TestC", testModelPath, false);
            var test4 = new TestData(fix2, "TestD", testModelPath, false);
            var test5 = new TestData(fix2, "TestE", @"C:\foo.rfa", false);

            cat1.Tests = new ObservableCollection<ITestData>() { test1, test2 };
            cat2.Tests = new ObservableCollection<ITestData>() { test3 };
            cat3.Tests = new ObservableCollection<ITestData>() { test4, test5 };

            fix1.Tests = new ObservableCollection<ITestData>() { test1, test2, test3 };
            fix2.Tests = new ObservableCollection<ITestData>() { test4, test5 };

            fix1.Assembly = assData;
            fix2.Assembly = assData;
            cat1.Assembly = assData;
            cat2.Assembly = assData;
            cat3.Assembly = assData;

            return new List<IAssemblyData>{assData};
        }