예제 #1
0
def assertProperty(property, expectation, i=0):
    assertAgainst = expectation[property]
    if property == "code":
        assertAgainst = [
            line[line.find(')') + 1:] for line in expectation[property][1:]
        ]
    assert testinggame._find_java_tests(
        expectation['code'])[i][property] == assertAgainst
예제 #2
0
def testParserToParseCodeInTestInClassExample():
    expectedCode = {
        'code': [
            ")    @Test", ")    public void testInClassExample() {",
            ")        Assert.assertEquals(0, 0);", ")",
            ")        Assert.assertEquals(0, 0);", ")",
            ")        Assert.assertEquals(0, 0);", ")    }"
        ]
    }
    property = 'code'
    parsedExpectedCode = [
        line[line.find(')') + 1:] for line in expectedCode[property][1:]
    ]
    assert testinggame._find_java_tests(
        testInClassExample['code'])[0][property] == parsedExpectedCode
예제 #3
0
def testParserToParseCodeInSmallSetupExample():
    expectedCode = {
        "code": [
            ")    @Test", ")    public void testSetupExample() {",
            ")        Square[][] grid = new Square[6][4];",
            ")        for (int x = 0; x < grid.length; x++) {",
            ")            for (int y = 0; y < grid[x].length; y++) {",
            ")                grid[x][y] = new BasicSquare();",
            ")            }", ")        }",
            ")        board = new Board(grid);",
            ")        Assert.assertEquals(0, 0);", ")",
            ")        Assert.assertEquals(0, 0);", ")",
            ")        Assert.assertEquals(0, 0);", ")    }"
        ]
    }
    property = 'code'
    parsedExpectedCode = [
        line[line.find(')') + 1:] for line in expectedCode[property][1:]
    ]
    assert testinggame._find_java_tests(
        smallSetupExample['code'])[0][property] == parsedExpectedCode
예제 #4
0
def testParserToParseCodeInSmallReferenceExample():
    expectedCode = {
        "code": [
            ")    @Test", ")    void win() {",
            ")        final int randomPoints = 42;",
            ")        when(level.isAnyPlayerAlive()).thenReturn(true);",
            ")        when(level.remainingPellets()).thenReturn(randomPoints);",
            ")", ")        game.start();", ")",
            ")        verify(level).start();",
            ")        verify(level).addObserver(game);",
            ")        assertThat(game.isInProgress()).isTrue();",
            ")        game.levelWon();",
            ")        assertThat(game.isInProgress()).isFalse();", ")    }"
        ]
    }
    property = 'code'
    parsedExpectedCode = [
        line[line.find(')') + 1:] for line in expectedCode[property][1:]
    ]
    assert testinggame._find_java_tests(
        smallReferenceExample['code'])[1][property] == parsedExpectedCode
예제 #5
0
def testParserToParseCodeInBigReferenceExample():
    expectedCode = {
        "code": [
            ")    @Test", ")    void stop() {",
            ")        MockitoAnnotations.initMocks(this);",
            ")        game = new SinglePlayerGame(player, level);",
            ")        final int randomPoints = 42;",
            ")        when(level.isAnyPlayerAlive()).thenReturn(true);",
            ")        when(level.remainingPellets()).thenReturn(randomPoints);",
            ")", ")        game.start();", ")",
            ")        verify(level).start();",
            ")        verify(level).addObserver(game);",
            ")        assertThat(game.isInProgress()).isTrue();",
            ")        game.stop();",
            ")        assertThat(game.isInProgress()).isFalse();",
            ")        verify(level).stop();", ")    }"
        ]
    }
    property = 'code'
    parsedExpectedCode = [
        line[line.find(')') + 1:] for line in expectedCode[property][1:]
    ]
    assert testinggame._find_java_tests(
        bigReferenceExample['code'])[1][property] == parsedExpectedCode