public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            fixtureResult.hasTest("broken describe").thatFails()
                .withFailureMessage("Attempted to divide by zero.");
        }
 public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
 {
     fixtureResult.failed();
     fixtureResult.hasTest("when in some context, then there is some text")
         .withFailureMessage("System.TimeZoneNotFoundException : no time!")
         .thatFailsInAnUnspecifiedManner();
 }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.succeeds();

            fixtureResult.hasTest("simple test");
            fixtureResult.hasTest("simple describe, simple test");
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            fixtureResult.hasTest("has a valid test").thatErrors()
                .withFailureMessage("System.InvalidOperationException : Called it() within beforeEach().");
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.succeeds();

            fixtureResult.containsTrace(@"
            creating some_observable_A
            creating some_observable_B
            creating some_observable_C
            disposing some_observable_C
            disposing some_observable_B
            disposing some_observable_A
            creating some_observable_A
            creating some_observable_B
            creating some_observable_D
            disposing some_observable_D
            disposing some_observable_B
            disposing some_observable_A
            creating some_observable_A
            creating some_observable_B
            creating some_observable_D
            creating some_observable_E
            creating some_observable_F
            disposing some_observable_F
            disposing some_observable_E
            disposing some_observable_D
            disposing some_observable_B
            disposing some_observable_A
            ");
        }
 public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
 {
     fixtureResult.failed();
     fixtureResult.containsTrace(@"
     failure_in_setup_doesnt_prevent_cleanup_in_same_scope
     failure_in_setup_doesnt_prevent_cleanup");
 }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            fixtureResult.hasTest("outer test").thatFailsInAnUnspecifiedManner()
                .withFailureMessage("System.InvalidOperationException : Called it() within it().");
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            fixtureResult.hasTestWithFullName("NJasmineTests.Specs.report_test_failures_usefully.reports_exception_at_outermost_scope").thatFails()
                .withFailureMessage("Attempted to divide by zero.");
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            fixtureResult.hasTest("passes the test if the condition passes").thatSucceeds();
            fixtureResult.hasTest("fails the test if if the condition fails").thatErrors();
            fixtureResult.hasTest("expections can be set during discovery, fails this test").thatErrors();
        }
Exemplo n.º 10
0
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.succeeds();

            fixtureResult.hasTest("given the environment is in a particular state, when the system under test is used in a particular manner, then a particular result is expected");
            fixtureResult.hasTest("given the environment is in a particular state, given the environment is in an even more particular state, when the system is used in another manner, then another result is expected");
            fixtureResult.hasTest("given the environment is in a particular state, given the environment is in an even more particular state, when the system is used in another manner, then yet another result is expected");
        }
 public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
 {
     fixtureResult.hasTest("shows stacktrace information for this failing test")
         .withDetailedMessageThat(message =>
         {
             Expect.That(() => Regex.Match(message, "at stacktrace_shows_fileposition_first.cs:\\d+ ").Success);
         });
 }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            var stackTrace = fixtureResult.withStackTraces().Single();
            Assert.That(stackTrace, Is.StringContaining("NJasmine.Core"));

            Assert.That(TestResultUtil.PatternForNJasmineAnonymousMethod.IsMatch(stackTrace));
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.succeeds();

            fixtureResult.hasSuite("given an outer block").thatsInconclusive().thatHasNoResults();

            fixtureResult.hasSuite("when ignore is set after a test").thatSucceeds()
                .ShouldHaveTest("NJasmineTests.Specs.can_mark_tests_as_ignored, when ignore is set after a test, then the earlier test runs")
                .thatSucceeds();
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.succeeds();

            fixtureResult.hasSuite("given an outer block").thatsInconclusive().thatHasNoResults();

            fixtureResult.hasSuite("when ignore is set after a test").thatSucceeds()
                .hasTest("then the earlier test runs")
                .thatSucceeds();
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            fixtureResult.hasTest("when the arrange code tries to re-enter, has a valid test that will now fail")
                .thatErrors()
                .withFailureMessage("System.InvalidOperationException : Called it() within arrange().");

            fixtureResult.hasTest("when the arrange cleanup code tries to re-enter, has a valid test that will now fail")
                .thatErrors()
                .withFailureMessage("System.InvalidOperationException : Called it() within arrange().");
        }
 public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
 {
     fixtureResult.succeeds();
     fixtureResult.containsTrace(@"
     First setup
     First test
     First cleanup
     First setup
     Second setup
     Second test
     Second cleanup
     First cleanup
     ");
 }
Exemplo n.º 17
0
        public override int Run()
        {
            var xmlOutput = File.ReadAllText(XmlOutputFile);
            var consoleOutput = File.ReadAllText(ConsoleOutputFile);

            var testType = typeof (can_check_that_an_arbtirary_condition_is_true).Assembly.GetType(TestName);
            var test = testType.GetConstructor(new Type[0]).Invoke(new Type[0]) as INJasmineInternalRequirement;

            var fixtureResult = new FixtureResult(TestName, xmlOutput, consoleOutput);

            test.Verify_NJasmine_implementation(fixtureResult);

            return 0;
        }
 public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
 {
     fixtureResult.succeeds();
     fixtureResult.containsTrace(@"
     one
     two
     three
     four
     -four
     -three
     -two
     -one
     ");
 }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            fixtureResult.hasTest("repeated outer test").thatErrors();
            fixtureResult.hasTest("repeated outer test`2").thatErrors();
            fixtureResult.hasTest("repeated outer test`3").thatErrors();

            fixtureResult.hasTest("repeated unimplemented outer test").thatIsNotRunnable();
            fixtureResult.hasTest("repeated unimplemented outer test`2").thatIsNotRunnable();
            fixtureResult.hasTest("repeated unimplemented outer test`3").thatIsNotRunnable();

            fixtureResult.hasTest("repeated describe, repeated inner describe").thatFails();
            fixtureResult.hasTest("repeated describe, repeated inner describe`2").thatFails();
            fixtureResult.hasTest("repeated describe, repeated inner describe`3").thatFails();
        }
Exemplo n.º 20
0
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.succeeds();

            var suite = fixtureResult.hasSuite("when using category Foo then Bar").withCategories();

            suite.hasTest("then tests have Foo").withCategories("Foo");

            suite.hasTest("then tests have Foo").withCategories("Foo");

            suite.hasTest("then tests have For and Bar").withCategories("Foo", "Bar");

            var nestedSuite = suite.hasSuite("when in a nested block and using a category").withCategories("Foo", "Bar");

            nestedSuite.hasTest("then the test only has category Baz").withCategories("Baz");
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            fixtureResult.hasTest("then reports the test with the correct count")
                .withFailureMessage("Failed with TotalRuns: 1");

            fixtureResult.hasTest("then reports the test with the correct count`2")
                .withFailureMessage("Failed with TotalRuns: 1");

            fixtureResult.hasTest("then reports the test with the correct count`3")
                .withFailureMessage("Failed with TotalRuns: 1");

            fixtureResult.hasTest("then reports the test with the correct count`4")
                .withFailureMessage("Failed with TotalRuns: 1");
        }
Exemplo n.º 22
0
        public override void Specify()
        {
            describe("thatsInconclusive()", delegate
            {
                it("allows results that are inconclusive", delegate
                {
                    var xmlOutput = FixtureResult.GetSampleXmlResult(aSuiteName: "fooSuite", aSuiteResult: "Inconclusive");

                    var sut = new FixtureResult("ignored", xmlOutput).hasSuite("fooSuite");

                    sut.thatsInconclusive();
                });

                it("gives an error indicating the actual result when not inconclusive", delegate
                {
                    var xmlOutput = FixtureResult.GetSampleXmlResult(aSuiteName: "fooSuite", aSuiteResult: "OtherResult");

                    var sut = new FixtureResult("ignored", xmlOutput).hasSuite("fooSuite");

                    var exception = Assert.Throws(FixtureResultTest.ExpectedAssertionType, delegate
                    {
                        sut.thatsInconclusive();
                    });

                    expect(() => exception.Message.Contains("fooSuite"));
                    expect(() => exception.Message.Contains("OtherResult"));
                });
            });

            describe("thatHasNoResults()", delegate
            {
                it("fails if the suite has results", delegate
                {
                    var sut = new FixtureResult("ignored",
                        FixtureResult.GetSampleXmlResult(aSuiteName: "someSuiteHello"))
                        .hasSuite("someSuiteHello");

                    var exception = Assert.Throws(FixtureResultTest.ExpectedAssertionType, delegate
                    {
                        sut.thatHasNoResults();
                    });

                    expect(() => exception.Message.Contains("someSuiteHello"));
                });
            });
        }
 public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
 {
     fixtureResult.succeeds();
     fixtureResult.containsTrace(@"
     BEFORE ALL
     first test
     SECOND BEFORE ALL
     INNER BEFORE ALL
     second test
     third test
     INNER AFTER ALL
     DISPOSING INNER BEFORE ALL
     SECOND AFTER ALL
     DISPOSING SECOND BEFORE ALL
     AFTER ALL
     DISPOSING BEFORE ALL
     ");
 }
Exemplo n.º 24
0
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.succeeds();

            fixtureResult.containsTrace(@"
            test started, before include of a
            FixtureSetup some_Nunit_fixture_a
            after include of a
            first describe, before include of b
            FixtureSetup some_Nunit_fixture_b
            after include of b
            test started, before include of a
            SetUp some_Nunit_fixture_a
            after include of a
            first describe, before include of b
            SetUp some_Nunit_fixture_b
            after include of b
            first test
            TearDown some_Nunit_fixture_b
            TearDown some_Nunit_fixture_a
            before include of c
            FixtureSetup some_Nunit_fixture_c
            after include of c
            test started, before include of a
            SetUp some_Nunit_fixture_a
            after include of a
            first describe, before include of b
            SetUp some_Nunit_fixture_b
            after include of b
            before include of c
            SetUp some_Nunit_fixture_c
            after include of c
            second test test
            TearDown some_Nunit_fixture_c
            TearDown some_Nunit_fixture_b
            TearDown some_Nunit_fixture_a
            FixtureTearDown some_Nunit_fixture_c
            FixtureTearDown some_Nunit_fixture_b
            FixtureTearDown some_Nunit_fixture_a
            ");
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.failed();

            fixtureResult.hasTest("waitUntil() or expectEventually() can be used to have the test wait until a condition passes, given a condition that eventually evaluates to true, a normal expect works when no waits are left")
                .thatSucceeds();

            fixtureResult.hasTest("waitUntil() or expectEventually() can be used to have the test wait until a condition passes, given a condition that eventually evaluates to true, a normal expect fails when waits are left")
                .thatErrors();

            fixtureResult.hasTest("waitUntil() or expectEventually() can be used to have the test wait until a condition passes, given a condition that eventually evaluates to true, waitUntil will try multiple times")
                .thatSucceeds();

            fixtureResult.hasTest("waitUntil() or expectEventually() can be used to have the test wait until a condition passes, given a condition that eventually evaluates to true, expectEventually will try multiple times")
                .thatSucceeds();

            fixtureResult.hasTest("waitUntil() or expectEventually() can be used to have the test wait until a condition passes, waitUntil can be called during discovery, doesnt prevent discovery")
                .thatErrors();

            fixtureResult.hasTest("waitUntil() or expectEventually() can be used to have the test wait until a condition passes, expectEventually can be called during discovery, doesnt prevent discovery")
                .thatErrors();
        }
 public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
 {
     fixtureResult.hasTest("does nothing if all substrings are present").thatSucceeds();
     fixtureResult.hasTest("fails if a substring is missing").thatErrors();
     fixtureResult.hasTest("fails if substrings are out of order").thatErrors();
 }
Exemplo n.º 27
0
        public override void Specify()
        {
            describe("succeeds()", delegate
            {
                it("allows a passing test result", delegate
                {
                    new FixtureResult(_expectedFixtureName, FixtureResult.GetSampleXmlResult(1)).succeeds();
                });

                var cases = new Dictionary<string, TestDelegate>();

                cases.Add("running against error", delegate
                {
                    var sut = new FixtureResult(_expectedFixtureName, FixtureResult.GetSampleXmlResult(1, 1));
                    sut.succeeds();
                });

                cases.Add("running against failure", delegate
                {
                    var sut = new FixtureResult(_expectedFixtureName, FixtureResult.GetSampleXmlResult(1, 0, 1));
                    sut.succeeds();
                });

                cases.Add("running against no tests", delegate
                {
                    var sut = new FixtureResult(_expectedFixtureName, FixtureResult.GetSampleXmlResult(0));
                    sut.succeeds();
                });

                CheckScenariosCauseErrorWithMessageContaining(cases, _expectedFixtureName);
            });

            describe("failed()", delegate
            {
                it("allows test results with errors or failures", delegate
                {
                    new FixtureResult(_expectedFixtureName, FixtureResult.GetSampleXmlResult(1, 1)).failed();
                    new FixtureResult(_expectedFixtureName, FixtureResult.GetSampleXmlResult(1, 0, 1)).failed();
                });

                CheckScenario("running against no tests", delegate
                {
                    var sut = new FixtureResult(_expectedFixtureName, FixtureResult.GetSampleXmlResult(0), "");
                    sut.failed();
                }, _expectedFixtureName);
            });

            describe("containsTrace", delegate
            {
                var originalXml = "<xml></xml>";

                string originalConsole = @"
            NUnit version 2.5.9.10348
            Copyright (C) 2002-2009 Charlie Poole.
            Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
            Copyright (C) 2000-2002 Philip Craig.
            All Rights Reserved.

            Runtime Environment -
               OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
              CLR Version: 2.0.50727.5446 ( Net 2.0 )

            ProcessModel: Default    DomainUsage: Single
            Execution Runtime: Default
            <<{{test started, before include of a}}>>
            <<{{after include of a}}>>
            <<{{first describe, before include of b}}>>
            <<{{after include of b}}>>
            <<{{before include of c}}>>
            <<{{after include of c}}>>
            Selected test(s): NJasmineTests.Specs.beforeAll.beforeAll_and_afterAll_are_applied_to_the_correct_scope
            .{{<<RESET>>}}
            <<{{BEFORE ALL}}>>
            <<{{first test}}>>
            .<<{{SECOND BEFORE ALL}}>>
            <<{{INNER BEFORE ALL}}>>
            <<{{second test}}>>
            .<<{{third test}}>>
            <<{{INNER AFTER ALL}}>>
            <<{{DISPOSING INNER BEFORE ALL}}>>
            <<{{SECOND AFTER ALL}}>>
            <<{{DISPOSING SECOND BEFORE ALL}}>>
            <<{{AFTER ALL}}>>
            <<{{DISPOSING BEFORE ALL}}>>

            Tests run: 3, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.0820047 seconds
            ";

                it("allows tests with the expected trace", delegate
                {
                    new FixtureResult(_expectedFixtureName, originalXml, originalConsole).containsTrace(@"
            BEFORE ALL
            first test
            SECOND BEFORE ALL
            INNER BEFORE ALL
            second test
            third test
            INNER AFTER ALL
            DISPOSING INNER BEFORE ALL
            SECOND AFTER ALL
            DISPOSING SECOND BEFORE ALL
            AFTER ALL
            DISPOSING BEFORE ALL
            ");
                });

                it("fails tests without the expected trace", delegate
                {
                    var sut = new FixtureResult(_expectedFixtureName, originalXml, originalConsole);

                    var exception = Assert.Throws(ExpectedAssertionType, delegate
                    {
                        sut.containsTrace(@"
            ONE
            TWO
            THREE
            ");
                    });

                    var message = exception.Message;

                    expect(() => message.IndexOf("ONE") < message.IndexOf("TWO"));
                    expect(() => message.IndexOf("TWO") < message.IndexOf("THREE"));

                    expect(() => message.IndexOf("BEFORE ALL") < message.IndexOf("INNER AFTER ALL"));
                    expect(() => message.IndexOf("INNER AFTER ALL") < message.IndexOf("DISPOSING BEFORE ALL"));

                    expect(() => message.Contains(_expectedFixtureName));
                });
            });

            describe("hasTest", delegate
            {
                var expectedTestName = "one_two_test";

                var xmlOutput = FixtureResult.GetSampleXmlResult(aTestName: _expectedFixtureName + ", " + expectedTestName);

                var sut = arrange(() => new FixtureResult(_expectedFixtureName, xmlOutput));

                it("returns a test by name", delegate
                {
                    expect(() => sut.hasTest(expectedTestName) != null);
                });

                it("gives a useful error message if the test is not found", delegate
                {
                    string wrongTestName = "fsadf325m";

                    var exception = Assert.Throws(ExpectedAssertionType, delegate
                    {
                        sut.hasTestWithFullName(wrongTestName);
                    });

                    expect(() => exception.Message.Contains("Expected test not found, expected test named " + wrongTestName));
                });
            });

            describe("hasSuite", delegate
            {
                var expectedSuiteName = "one_two_test";

                var xmlOutput = FixtureResult.GetSampleXmlResult(aSuiteName: expectedSuiteName);

                var sut = arrange(() => new FixtureResult(_expectedFixtureName, xmlOutput));

                it("returns a test suite by name", delegate
                {
                    expect(() => sut.hasSuite(expectedSuiteName) != null);
                });

                it("gives a useful error message if the test suite is not found", delegate
                {
                    string wrongSuiteName = "9vasjf9d";

                    var exception = Assert.Throws(ExpectedAssertionType, delegate
                    {
                        sut.hasSuite(wrongSuiteName);
                    });

                    expect(() => exception.Message.Contains("Expected test suite not found, expected suite named '" + wrongSuiteName));
                });
            });

            describe("withStackTraces()", delegate
            {
                string fullTrace = "foo bar baz";

                it("it returns the stacktraces in a fixture result", delegate
                {
                    var sut = arrange(() => new FixtureResult(_expectedFixtureName,
                                                FixtureResult.GetSampleXmlResult(aStackTrace: fullTrace)));

                    expect(() => sut.withStackTraces().Single() == fullTrace);
                });
            });
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.hasTest("an unimplemented test() block").thatIsNotRunnable();

            fixtureResult.hasTest("nested too of course, an unimplemented test() block").thatIsNotRunnable();
        }
        public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
        {
            fixtureResult.hasTest("trace information is not included on success, is a passing test")
                .thatSucceeds();

            fixtureResult.hasTest("trace information is included on failure, is a failing test")
                .thatErrors()
                .withDetailedMessageThat(
                    message => Expect.That(message).ContainsInOrder(
                        "d e f",
                        "1 2 3",
                        "g h i",
                        "j k l"));

            fixtureResult.hasTest("globally tracked trace information only applies to the correct scope, scope with trace, test with trace")
                .thatErrors().withDetailedMessageThat(message =>
                Assert.That(message, Is.StringContaining(ParticularyScopedTraceMessage)));

            fixtureResult.hasTest("globally tracked trace information only applies to the correct scope, test without trace")
                .thatErrors().withDetailedMessageThat(message =>
                Assert.That(message, Is.Not.StringContaining(ParticularyScopedTraceMessage)));

            fixtureResult.hasTest("trace messages can be recorded during per-test cleanup, test with cleanup")
                .thatErrors().withDetailedMessageThat(message => Assert.That(message, Is.StringContaining("traced after test")));

            fixtureResult.hasTest("trace messages during global cleanup cause a failure of next test, test with global cleanup")
                .thatSucceeds();

            fixtureResult.hasTest("forced to fail by previous error")
                .thatErrors().withFailureMessage("Attempted to call trace() from within afterAll");
        }
Exemplo n.º 30
0
 public void Verify_NJasmine_implementation(FixtureResult fixtureResult)
 {
     fixtureResult.hasTest("given some precondition, when the input is 0, then it runs").thatSucceeds();
     fixtureResult.hasTest("given some precondition, when the input is 1, then it runs").thatSucceeds();
 }