Testing JUnit测试只运行一次

Testing JUnit测试只运行一次,testing,gradle,groovy,junit,Testing,Gradle,Groovy,Junit,我有一个简单的JUnit测试。 如果我运行它,一切正常。如果我试着在最后一次之后运行它,它只是忽略了测试,并且没有做测试就完成了。当我等待一段时间,比如5分钟,然后它再次正常工作,直到我尝试在尝试之后立即运行它 对于我的测试,我将groovy与gradle一起使用,这是一个gebish测试 是否有一个我必须改变的“触发器”,我可以随时运行测试 这是我的测试用例: @RunWith(JUnit4) class TestClass extends GebReportingTest { @Te

我有一个简单的JUnit测试。 如果我运行它,一切正常。如果我试着在最后一次之后运行它,它只是忽略了测试,并且没有做测试就完成了。当我等待一段时间,比如5分钟,然后它再次正常工作,直到我尝试在尝试之后立即运行它

对于我的测试,我将groovy与gradle一起使用,这是一个gebish测试

是否有一个我必须改变的“触发器”,我可以随时运行测试

这是我的测试用例:

@RunWith(JUnit4)
class TestClass extends GebReportingTest {
    @Test
    void justATest() {
        go "http://stackoverflow.com"

        assert $("#h-top-questions").text() == "Top Questions"

        go "http://google.com"
    }
}
这是我的身材。格雷德尔:

def browserstackUsername = ""
def browserstackKey = ""

apply plugin: 'groovy'


def gebVersion = '0.13.1'
def seleniumVersion = '2.51.0'

repositories {
    mavenCentral()
}

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.gebish:geb-gradle:0.13.1'
    }
}

dependencies {
    testCompile "org.gebish:geb-gradle:$gebVersion"

    testRuntime "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
    testCompile "org.gebish:geb-junit4:$gebVersion"

    testCompile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
}

task firefoxTest(type: Test) {
    systemProperty "geb.build.reportsDir", reporting.file("$name/geb")
    systemProperty "geb.env", "firefox"
}

task browserstackTest(type: Test){
    systemProperty "geb.build.reportsDir", reporting.file("$name/geb")
    systemProperty "geb.env", "browserstack"

    apply plugin: "geb-browserstack"

    // Config: http://www.gebish.org/manual/current/#geb-browserstack-plugin
    browserStack {
        def applicationAddresses = [8000, 8080, 8888, 9000, 9090].collect { "http://localhost:$it" }
        application(*applicationAddresses)

        forceLocal = true
        browsers {
            firefox_windows
        }
        account {
            username = browserstackUsername
            accessKey = browserstackKey
        }
    }
}

如果您刚刚运行了测试,并且测试通过了,并且您没有更改任何内容,那么测试将被跳过,因为它显然会再次通过为什么?网页可以随时更改。那我检查一个一直在变化的日志呢?正因为如此,我正在寻找一种解决方案来关闭跳过。一个“干净的构建”应该再次运行测试,但这也会重建您的项目-有一种方法可以使任务在您的Gradle构建中始终“不是最新的”,但我不记得此时是如何进行的。