Esempio n. 1
0
 /// <inheritdoc />
 protected override void Execute(UnmanagedTestRepository repository, IProgressMonitor progressMonitor)
 {
     using (progressMonitor.BeginTask("Exploring " + repository.FileName, 1))
     {
         BuildTestModel(repository, progressMonitor);
     }
 }
Esempio n. 2
0
        /// <inheritdoc />
        protected override void Execute(UnmanagedTestRepository repository, IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask("Running " + repository.FileName, 4))
            {
                progressMonitor.SetStatus("Building the test model.");
                BuildTestModel(repository, progressMonitor);
                progressMonitor.Worked(1);

                progressMonitor.SetStatus("Running the tests.");
                RunTests(repository, progressMonitor);
                progressMonitor.Worked(3);
            }
        }
        public void GetTests()
        {
            using (var repository = new UnmanagedTestRepository(resources))
            {
                Assert.IsTrue(repository.IsValid);
                TestInfoData[] items = repository.GetTests().ToArray();
                Assert.IsNotEmpty(items);

                using (TestLog.BeginSection(String.Format("Found {0} test item(s):", items.Length)))
                {
                    foreach (TestInfoData item in items)
                    {
                        DiagnosticLog.WriteLine("{0}: Fixture={1}, Test={2}, Row={3}, Kind={4}", 
                            item.Name, item.Native.Position.pTestFixture, item.Native.Position.pTest, 
                            item.Native.Position.pRow, item.Kind);
                    }
                }
            }
        }
Esempio n. 4
0
        private void RunTests(UnmanagedTestRepository repository, IProgressMonitor progressMonitor)
        {
            ITestContextManager testContextManager = new ObservableTestContextManager(TestContextTrackerAccessor.Instance, MessageSink);
            ITestCommandFactory testCommandFactory = new DefaultTestCommandFactory();
            ITestCommand rootTestCommand = testCommandFactory.BuildCommands(TestModel, TestExecutionOptions.FilterSet, TestExecutionOptions.ExactFilter, testContextManager);
            reporter = new AssertionFailureReporter(repository);
            this.repository = repository;

            if (rootTestCommand != null)
            {
                if (TestExecutionOptions.SkipTestExecution)
                {
                    SkipAll(rootTestCommand, null);
                }
                else
                {
                    RunAll(progressMonitor, rootTestCommand);
                }
            }
        }
Esempio n. 5
0
        /// <inheritdoc />
        protected sealed override object RunImpl(object[] args)
        {
            TestPackage = (TestPackage)args[0];
            TestExplorationOptions = (TestExplorationOptions)args[1];
            TestExecutionOptions = (TestExecutionOptions)args[2];
            MessageSink = (IMessageSink)args[3];
            var progressMonitor = (IProgressMonitor)args[4];
            Logger = (ILogger)args[5];
            var fileInfo = (FileInfo)args[6];
            TestModel = new TestModel();

            using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1))
            {
                if (!subProgressMonitor.IsCanceled)
                {
                    using (var repository = new UnmanagedTestRepository(fileInfo.FullName))
                    {
                        if (repository.IsValid)
                        {
                            Execute(repository, subProgressMonitor); 
                        }
                    }
                }
            }

            return null;
        }
Esempio n. 6
0
        /// <summary>
        /// Builds the test model.
        /// </summary>
        /// <param name="repository">The MbUnitCpp unmanaged test repository.</param>
        /// <param name="progressMonitor">The active progress monitor for the task.</param>
        protected void BuildTestModel(UnmanagedTestRepository repository, IProgressMonitor progressMonitor)
        {
            Test fixture = null;
            Test group = null;
            var root = repository.CreateRootTest();
            TestModel.RootTest.AddChild(root);

            foreach (var testInfoData in repository.GetTests())
            {
                if (progressMonitor.IsCanceled)
                    return;

                var test = new MbUnitCppTest(testInfoData, repository);

                switch (testInfoData.Kind)
                {
                    case NativeTestKind.Fixture:
                        fixture = test;
                        root.AddChild(fixture);
                        break;
                
                    case NativeTestKind.Test:
                        fixture.AddChild(test);
                        break;

                    case NativeTestKind.Group:
                        group = test;
                        fixture.AddChild(group);
                        break;

                    case NativeTestKind.RowTest:
                        test.Name = group.Name + ((test.Name.Length > 0) ? String.Format(" ({0})", test.Name) : String.Empty);
                        group.AddChild(test);
                        break;
             
                    default:
                        throw new ModelException(String.Format("Unexpected or invalid MbUnitCpp test kind '{0}'.", testInfoData.Kind));
                }
            }

            TestModelSerializer.PublishTestModel(TestModel, MessageSink);
        }
Esempio n. 7
0
 /// <summary>
 /// Executes the tasks.
 /// </summary>
 /// <param name="repository">The MbUnitCpp unmanaged test repository.</param>
 /// <param name="progressMonitor">The active progress monitor for the task.</param>
 protected abstract void Execute(UnmanagedTestRepository repository, IProgressMonitor progressMonitor);
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="repository">The unmanaged test repository.</param>
 public AssertionFailureReporter(UnmanagedTestRepository repository)
 {
     this.repository = repository;
 }