Пример #1
0
    GwtTestRunnerTest.prototype.test_continuesFromsCantBeChainedAcrossSuitesWithoutNamespacing = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        describe("test-suite #1", function() {
            it('test #1', function()
            {
                oTestRunner.doGiven("fixture.prop = 'value1'");
            });
        });

        describe("test-suite #2", function() {
            it('test #2', function()
            {
                oTestRunner.doGiven("test.continuesFrom = 'test #1'");
                oTestRunner.doGiven("fixture.prop = 'value2'");
            });
        });

        assertException(function() {
            oTestRunner.doGiven("test.continuesFrom = 'test #2'");
            oTestRunner.doGiven("fixture.prop = 'value3'");
            oTestRunner.doThen("fixture.prop = 'value3'");
        }, Errors.INVALID_TEST);
    };
Пример #2
0
    GwtTestRunnerTest.prototype.test_chainedTestsCanReferToOtherLocalTestsUsingLocalNames = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        describe("test-suite #1", function() {
            it('test #1', function()
            {
                oTestRunner.doGiven("fixture.prop = 'value1'");
            });

            it('test #2', function()
            {
                oTestRunner.doGiven("test.continuesFrom = 'test #1'");
                oTestRunner.doGiven("fixture.prop = 'value2'");
            });
        });

        describe("test-suite #2", function() {
        });

        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", "value1");
        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", "value2");
        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", "value3");

        oTestRunner.doGiven("test.continuesFrom = 'test-suite #1::test #2'");
        oTestRunner.doGiven("fixture.prop = 'value3'");
        oTestRunner.doThen("fixture.prop = 'value3'");
        oTestRunner.endTest();
    };
Пример #3
0
    GwtTestRunnerTest.prototype.test_xdescribeCanBeUsedToDisableTestSuitesWithoutBreakingChaining = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        xdescribe("test-suite #1", function() {
            it('test #1', function()
            {
                oTestRunner.doGiven("fixture.prop = 'value1'");
            });
        });

        describe("test-suite #2", function() {
            it('test #2', function()
            {
                oTestRunner.doGiven("test.continuesFrom = 'test-suite #1::test #1'");
                oTestRunner.doGiven("fixture.prop = 'value2'");
            });
        });

        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", "value1");
        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", "value2");
        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", "value3");

        oTestRunner.doGiven("test.continuesFrom = 'test #2'");
        oTestRunner.doGiven("fixture.prop = 'value3'");
        oTestRunner.doThen("fixture.prop = 'value3'");
        oTestRunner.endTest();
    };
Пример #4
0
    GwtTestRunnerTest.prototype.test_subFixturesCanBeAddresedViaChainedParents = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "grandParentFixture").getChildMockFixture().getFirstMockFixture().expects(once()).doGiven("prop", "value");
        oTestRunner.doGiven("grandParentFixture.childFixture.subFixture1.prop = 'value'");
    };
Пример #5
0
    GwtTestRunnerTest.prototype.test_apostrophesInStringValuesAreAllowed = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", "prop's value");
        oTestRunner.doGiven("fixture.prop = 'prop's value'");
    };
Пример #6
0
    GwtTestRunnerTest.prototype.test_fixtureNameCanContainEqualsSign = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "another=fixture");

        oTestRunner.doGiven("another=fixture.prop = 'value'");
    };
Пример #7
0
    GwtTestRunnerTest.prototype.test_stringsMustBeQuoted = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        assertException(function(){
            oTestRunner.doGiven("fixture.prop = foo bar");
        }, "");
    };
Пример #8
0
    GwtTestRunnerTest.prototype.test_arrayValuesAreAllowed = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", ["value", 42, true]);

        oTestRunner.doGiven("fixture.prop = ['value', 42, true]");
    };
Пример #9
0
    GwtTestRunnerTest.prototype.test_numbersValuesAreAllowed = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", 42);

        oTestRunner.doGiven("fixture.prop = 42");
    };
Пример #10
0
    GwtTestRunnerTest.prototype.test_propertyMustExist = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        assertException(function(){
            oTestRunner.doGiven("fixture.nonExistentProperty = 'value'");
        }, "");
    };
Пример #11
0
    GwtTestRunnerTest.prototype.test_statementsMustHaveAValue = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        assertException(function(){
            oTestRunner.doGiven("fixture.prop = ");
        }, "");
    };
Пример #12
0
    GwtTestRunnerTest.prototype.test_normalFixturesCantBeUsedAsPropertyFixtures = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        assertException(function(){
            oTestRunner.doGiven("fixture = 'value'");
        }, "");
    };
Пример #13
0
    GwtTestRunnerTest.prototype.test_propertyFixturesDontRequireADot = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "propertyFixture").expects(once()).doGiven("", "value");

        oTestRunner.doGiven("propertyFixture = 'value'");
    };
Пример #14
0
    GwtTestRunnerTest.prototype.test_andFirstCausesException = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        assertException(function(){
            oTestRunner.doAnd("fixture.prop = 'value'");
        }, "InvalidPhaseError");
    };
Пример #15
0
    GwtTestRunnerTest.prototype.test_propertyFixturesCanAlsoBeUsedNormally = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "propertyFixture").expects(once()).doGiven("prop", "value");

        oTestRunner.doGiven("propertyFixture.prop = 'value'");
    };
Пример #16
0
    GwtTestRunnerTest.prototype.test_ifYouHaveADotYouMustProvideAPropertyNameToo = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        assertException(function(){
            oTestRunner.doGiven("propertyFixture. = 'value'");
        }, "");
    };
Пример #17
0
    GwtTestRunnerTest.prototype.test_givenThenIsAllowed = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        oTestRunner.doGiven("fixture.prop = 'value'");
        oTestRunner.doThen("fixture.prop = 'value'");
        oTestRunner.endTest();
    };
Пример #18
0
    GwtTestRunnerTest.prototype.test_whenAfterThenCausesException = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        assertException(function(){
            oTestRunner.doWhen("fixture.prop => 'value'");
        }, "InvalidPhaseError");
    };
Пример #19
0
    GwtTestRunnerTest.prototype.test_valuesWithNewLinesAreParsedProperly = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "propertyFixture").expects(once()).doGiven("prop", "1\n2");
        this.getFixture(oTestRunner, "propertyFixture").expects(once()).doGiven("prop", "1\n2\n3\n4");

        oTestRunner.doGiven("propertyFixture.prop = '1\n2'");
        oTestRunner.doGiven("propertyFixture.prop = '1\n2\n3\n4'");
    };
Пример #20
0
    GwtTestRunnerTest.prototype.test_booleansValuesAreAllowed = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", true);
        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", false);

        oTestRunner.doGiven("fixture.prop = true");
        oTestRunner.doGiven("fixture.prop = false");
    };
Пример #21
0
    GwtTestRunnerTest.prototype.test_givenOnlyCausesException = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        oTestRunner.doGiven("fixture.prop = 'value'");

        assertException(function(){
            oTestRunner.endTest();
        }, "UnterminatedTestError");
    };
Пример #22
0
    GwtTestRunnerTest.prototype.test_exceptionIsThrownIfContinuingFromANonExistentTest = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        describe("some test suite", function() {
        });

        assertException(function(){
            oTestRunner.doGiven("test.continuesFrom = 'test #1'");
        }, "");
    };
Пример #23
0
    GwtTestRunnerTest.prototype.test_whensMustUseBecomesAndNotEquals = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        oTestRunner.doGiven("fixture.prop = 'value'");

        assertException(function(){
            oTestRunner.doWhen("fixture = 'value'");
        }, "");
    };
Пример #24
0
    GwtTestRunnerTest.prototype.test_StatementValueCanContainSymbols = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "propertyFixture").expects(once()).doGiven("prop", "value & key");
        oTestRunner.doGiven("propertyFixture.prop = 'value & key'");

        this.getFixture(oTestRunner, "propertyFixture").expects(once()).doGiven("prop", "value :@~#?!£$%^&* key");
        oTestRunner.doGiven("propertyFixture.prop = 'value :@~#?!£$%^&* key'");

    };
Пример #25
0
    GwtTestRunnerTest.prototype.test_subFixturesCanBeAddressedViaParent = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();

        this.getFixture(oTestRunner, "parentFixture").getFirstMockFixture().expects(once()).doGiven("prop", "value");
        oTestRunner.doGiven("parentFixture.subFixture1.prop = 'value'");

        Mock4JS.verifyAllMocks();

        this.getFixture(oTestRunner, "parentFixture").getSecondMockFixture().expects(once()).doGiven("prop", "value2");
        oTestRunner.doGiven("parentFixture.subFixture2.prop = 'value2'");
    };
Пример #26
0
    GwtTestRunnerTest.prototype.test_DottedNotationForGlobalsIsAllowed = function()
    {
        window.br = window.br || {};
        window.br.test = window.br.test || {};
        window.br.test.TestFixtureFactory = window.br.test.TestFixtureFactory || require("br/test/TestFixtureFactory");

        var oTestRunner = new GwtTestRunner("br.test.TestFixtureFactory");
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        oTestRunner.doGiven("fixture.prop = 'value'");
        oTestRunner.doWhen("fixture.prop => 'value'");
        oTestRunner.doThen("fixture.prop = 'value'");
        oTestRunner.endTest();
    };
Пример #27
0
    GwtTestRunnerTest.prototype.test_andsCanBeChained = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        oTestRunner.doGiven("fixture.prop = 'value'");
        oTestRunner.doAnd("fixture.prop = 'value'");
        oTestRunner.doAnd("fixture.prop = 'value'");

        oTestRunner.doWhen("fixture.prop => 'value'");
        oTestRunner.doAnd("fixture.prop => 'value'");
        oTestRunner.doAnd("fixture.prop => 'value'");

        oTestRunner.doThen("fixture.prop = 'value'");
        oTestRunner.doAnd("fixture.prop = 'value'");
        oTestRunner.doAnd("fixture.prop = 'value'");

        oTestRunner.endTest();
    };
Пример #28
0
    GwtTestRunnerTest.prototype.test_continuesFromRunsEarlierLinkInTestChain = function()
    {
        var oTestRunner = new GwtTestRunner(TestFixtureFactory);
        oTestRunner.startTest();
        this.stubMockFixture(oTestRunner, "fixture");

        describe("test-suite #1", function()
        {
            it("test #1", function()
            {
                oTestRunner.doGiven("fixture.prop = 'value1'");
            });
        });

        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", "value1");
        this.getFixture(oTestRunner, "fixture").expects(once()).doGiven("prop", "value2");

        oTestRunner.doGiven("test.continuesFrom = 'test #1'");
        oTestRunner.doGiven("fixture.prop = 'value2'");
        oTestRunner.doThen("fixture.prop = 'value2'");
        oTestRunner.endTest();
    };
Пример #29
0
	GwtTestRunnerTest.prototype.test_continuesFromsCanBeChainedMultipleTimes = function()
	{
		var oTestRunner = new GwtTestRunner(TestFixtureFactory);
		oTestRunner.startTest();
		this.stubMockFixture(oTestRunner, "fixture");

		describe("test-suite #1", function() {
			it('test #1', function() {
			oTestRunner.doGiven("fixture.prop = 'value1'");
			});

			it('test #2', function() {
			oTestRunner.doGiven("test.continuesFrom = 'test #1'");
			oTestRunner.doGiven("fixture.prop = 'value2'");
			});

			it('test #3', function() {
			oTestRunner.doGiven("test.continuesFrom = 'test #2'");
			oTestRunner.doGiven("fixture.prop = 'value2'");
			});

			it('test #4', function() {
			oTestRunner.doGiven("test.continuesFrom = 'test #3'");
			oTestRunner.doGiven("fixture.prop = 'value2'");
			});


			it('test #5', function() {
			oTestRunner.doGiven("test.continuesFrom = 'test #4'");
			oTestRunner.doGiven("fixture.prop = 'value2'");
			});


			it('test #6', function() {
			oTestRunner.doGiven("test.continuesFrom = 'test #5'");
			oTestRunner.doGiven("fixture.prop = 'value2'");
			});

			it('test #7', function() {
			oTestRunner.doGiven("test.continuesFrom = 'test #6'");
			oTestRunner.doGiven("fixture.prop = 'value2'");
			});

			it('test #8', function() {
			oTestRunner.doGiven("test.continuesFrom = 'test #7'");
			oTestRunner.doGiven("fixture.prop = 'value2'");
			});

			it('test #9', function() {
			oTestRunner.doGiven("test.continuesFrom = 'test #8'");
			oTestRunner.doGiven("fixture.prop = 'value2'");
			});

			it('test #10', function() {
				oTestRunner.doGiven("test.continuesFrom = 'test #9'");
				oTestRunner.doGiven("fixture.prop = 'value2'");
			});

			it('test #11', function() {
				oTestRunner.doGiven("test.continuesFrom = 'test #10'");
				oTestRunner.doGiven("fixture.prop = 'value2'");
			});
		});

		oTestRunner.doGiven("test.continuesFrom = 'test #11'");
		oTestRunner.doGiven("fixture.prop = 'value3'");
		oTestRunner.doThen("fixture.prop = 'value3'");
		oTestRunner.endTest();
	};