private static TestSession CreateTestSessionWithTwoTestRuns()
        {
            TestRun testRun1 = new TestRunBuilder()
                               .WithTestId(new TestId(TestId.TestKind.Unidentified, 1))
                               .WithTestName("Test 1")
                               .WithTestDescription("Test description 1")
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 1"))
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 2"))
                               .WithDurationMillis(100L)
                               .Build();

            TestRun testRun2 = new TestRunBuilder()
                               .WithTestId(new TestId(TestId.TestKind.Unidentified, 2))
                               .WithTestName("Test 2")
                               .WithTestDescription("Test description 2")
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 1"))
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 2"))
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 3"))
                               .WithDurationMillis(100L)
                               .Build();

            var testRuns = new List <TestRun> {
                testRun1, testRun2
            };

            TestSession testSession = new TestSessionBuilder()
                                      .WithTestRuns(testRuns)
                                      .WithTestSummary(new TestSummary(0, 0, 0))
                                      .Build();

            return(testSession);
        }
        public void ShouldGenerateReportWithSummaryForAddmlFlatFile()
        {
            TestRun testRun1 = new TestRunBuilder()
                               .WithDurationMillis(100L)
                               .WithTestId(new TestId(TestId.TestKind.Addml, 0))
                               .WithTestName("Test 1")
                               .WithTestDescription("Test description 1")
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 1"))
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 2"))
                               .Build();

            var testRuns = new List <TestRun> {
                testRun1
            };

            TestSession testSession = new TestSessionBuilder()
                                      .WithArchive(new Archive(ArchiveType.Noark3, null, null))
                                      .WithTestSummary(new TestSummary(41, 42, 0))
                                      .WithTestRuns(testRuns)
                                      .Build();

            testSession.TestSummary = new TestSummary(42, 43, 44);

            string html = GenerateReport(testSession);

            // xunit was not very happy to report errors on a very huge string
            html.Contains("Antall filer").Should().BeTrue();
            html.Contains("Antall poster").Should().BeTrue();
        }
        public void ShouldGenerateReport()
        {
            TestRun testRun1 = new TestRunBuilder()
                               .WithDurationMillis(100L)
                               .WithTestName("Test 1")
                               .WithTestDescription("Test description 1")
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 1"))
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 2"))
                               .Build();

            TestRun testRun2 = new TestRunBuilder()
                               .WithDurationMillis(100L)
                               .WithTestName("Test 2")
                               .WithTestDescription("Test description 2")
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 1"))
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 2"))
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 3"))
                               .Build();

            List <TestRun> testRuns = new List <TestRun> {
                testRun1, testRun2
            };

            TestSession testSession = new TestSessionBuilder()
                                      .WithTestRuns(testRuns)
                                      .WithTestSummary(new TestSummary(0, 0, 0))
                                      .Build();

            string html = GenerateReport(testSession);

            html.Should().Contain("<html");
            html.Should().Contain("Test 1");
            html.Should().Contain("Test 2");
            html.Should().Contain("</html>");
        }
Exemple #4
0
        public void ShouldGenerateReportWithSummaryForNoark5()
        {
            TestRun testRun1 = new TestRunBuilder()
                               .WithDurationMillis(100L)
                               .WithTestName("Test 1")
                               .WithTestDescription("Test description 1")
                               .WithTestCategory("Testkategori 1")
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 1"))
                               .WithTestResult(new TestResult(ResultType.Error, new Location("location"), "Test result 2"))
                               .Build();

            List <TestRun> testRuns = new List <TestRun> {
                testRun1
            };

            TestSession testSession = new TestSessionBuilder()
                                      .WithArchive(new Archive(ArchiveType.Noark5, null, null))
                                      .WithTestSummary(new TestSummary(0, 0, 44))
                                      .WithTestRuns(testRuns)
                                      .Build();

            string html = GenerateReport(testSession);

            // xunit was not very happy to report errors on a very huge string
            html.Contains("Antall filer").Should().BeTrue();
            html.Contains("Antall poster").Should().BeFalse();
        }
Exemple #5
0
        public void StartShouldUpdateTestRunConfiguration()
        {
            var loggerEvents = new MockTestLoggerEvents();
            var run          = new TestRunBuilder().Subscribe(loggerEvents).Build();

            loggerEvents.RaiseTestRunStart(this.testRunCriteria);

            Assert.IsNotNull(run.RunConfiguration);
            Assert.AreEqual("/tmp/test.dll", run.RunConfiguration.AssemblyPath);
            Assert.AreEqual(".NETCoreApp,Version=v5.0", run.RunConfiguration.TargetFramework);
            Assert.IsNotNull(run.RunConfiguration.StartTime);
        }
Exemple #6
0
    public void TestRunBuilder_CreateRunInfo()
    {
        var builder = new TestRunBuilder();
        var run     = builder.CreateRunInfo();

        Assert.Greater(run.Dependencies.Count, 0);
        Assert.IsFalse(string.IsNullOrEmpty(run.Editor.Branch));
        Assert.IsFalse(string.IsNullOrEmpty(run.Editor.Version));
        Assert.NotNull(run.Player);
        Assert.IsNull(run.Player.Platform);
        Assert.AreEqual(0, run.Results.Count);
    }
Exemple #7
0
    public void TestRunBuilder_GetPerformanceTestRun()
    {
        var builder = new TestRunBuilder();
        var run     = builder.GetPerformanceTestRun();

        Assert.Greater(run.Dependencies.Count, 0);
        Assert.NotNull(run.Editor);
        Assert.NotNull(run.Player);
        Assert.NotNull(run.Hardware);
        Assert.NotNull(run.TestSuite);
        Assert.NotNull(run.Date);
        Assert.AreEqual(0, run.Results.Count);
    }
Exemple #8
0
        public void MessageShouldStoreRunMessages()
        {
            var testRun      = new TestRunBuilder().WithStore(this.store).Build();
            var messageEvent = new TestRunMessageEventArgs(
                TestMessageLevel.Informational,
                "Dummy message");

            testRun.Message(messageEvent);

            testRun.Store.Pop(out _, out var messages);
            Assert.AreEqual(1, messages.Count);
            Assert.AreEqual(TestMessageLevel.Informational, messages[0].Level);
            Assert.AreEqual("Dummy message", messages[0].Message);
        }
        public void CompleteShouldWriteTestResultsForRelativeLogFilePath()
        {
            var relativePathTestRun = new TestRunBuilder()
                                      .WithLoggerConfiguration(new LoggerConfiguration(new () { { LoggerConfiguration.LogFilePathKey, "results.json" } }))
                                      .WithFileSystem(this.fileSystem)
                                      .WithConsoleOutput(new FakeConsoleOutput())
                                      .WithStore(new TestResultStore())
                                      .WithSerializer(new JsonTestResultSerializer())
                                      .Build();

            SimulateTestResult(relativePathTestRun);

            relativePathTestRun.Complete(this.testRunCompleteEvent);

            var logFilePath = relativePathTestRun.LoggerConfiguration.LogFilePath;

            Assert.IsFalse(string.IsNullOrEmpty(this.fileSystem.Read(logFilePath)));
        }
Exemple #10
0
    public void Metadata_GetFromResources()
    {
        var builder = new TestRunBuilder();

        builder.Setup();

        var run = Metadata.GetFromResources();

        Assert.Greater(run.Dependencies.Count, 0);
        Assert.NotNull(run.Editor);
        Assert.NotNull(run.Player);
        Assert.NotNull(run.Hardware);
        Assert.NotNull(run.TestSuite);
        Assert.NotNull(run.Date);
        Assert.AreEqual(0, run.Results.Count);

        builder.Cleanup();
    }