gpt4 book ai didi

grails - 我无法使用 Geb 和 spock 运行简单的 Grails 功能测试

转载 作者:行者123 更新时间:2023-12-01 18:10:52 25 4
gpt4 key购买 nike

我寻求帮助,因为我不知道如何处理此错误...首先让我展示一下运行我的非常简单的测试时得到的堆栈跟踪,奇怪的是我的测试似乎没有被执行......?我正在使用 Grails 2.0

Configuring Spring Security Core ...
... finished configuring Spring Security Core
| Server running. Browse to http://localhost:8080/
| Running 3 functional tests... 1 of 0
| Failure: initializationError(SecondaryTest)
| java.lang.Exception: No runnable methods
at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:166)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:102)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:344)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:74)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:55)
| Running 3 functional tests... 2 of 0
| Failure: initializationError(SecondaryTest)
| java.lang.Exception: The @Rule '_gebReportingSpecTestName' must be public.

at org.junit.internal.runners.rules.RuleFieldValidator.addError(RuleFieldValidator.java:90)
at org.junit.internal.runners.rules.RuleFieldValidator.validatePublic(RuleFieldValidator.java:67)
at org.junit.internal.runners.rules.RuleFieldValidator.validateField(RuleFieldValidator.java:55)
at org.junit.internal.runners.rules.RuleFieldValidator.validate(RuleFieldValidator.java:50)
at org.junit.runners.BlockJUnit4ClassRunner.validateFields(BlockJUnit4ClassRunner.java:170)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:344)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:74)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:55)
| Running 3 functional tests... 3 of 0
| Failure: initializationError(SecondaryTest)
| java.lang.Exception: The @Rule '_gebReportingSpecTestName' must implement MethodRule or TestRule.
at org.junit.internal.runners.rules.RuleFieldValidator.addError(RuleFieldValidator.java:90)
at org.junit.internal.runners.rules.RuleFieldValidator.validateTestRuleOrMethodRule(RuleFieldValidator.java:73)
at org.junit.internal.runners.rules.RuleFieldValidator.validateField(RuleFieldValidator.java:56)
at org.junit.internal.runners.rules.RuleFieldValidator.validate(RuleFieldValidator.java:50)
at org.junit.runners.BlockJUnit4ClassRunner.validateFields(BlockJUnit4ClassRunner.java:170)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:344)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:74)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:55)
| Completed 3 functional tests, 3 failed in 40ms
| Server stopped
| Tests FAILED - view reports in target/test-reports

这里是常规文件:

SecondaryTest.groovy:

import pages.SignInPage
import geb.spock.GebReportingSpec

class SecondaryTest extends GebReportingSpec {

String getBaseUrl() { "http://localhost:8080/" }

File getReportDir() { new File("target/reports/geb") }

def "I am at siginin page"() {
when:
to SignInPage

then:
true
}
}

SignInPage.groovy:

package pages

import geb.Page

class SignInPage extends Page {

static url = "login/auth"

static at = { title == "Sign in" }

static content = {
}
}

谢谢

最佳答案

您的测试类必须以 Spec 结尾,而不是 Test。否则 Grails 不会将它们识别为 Spock 规范。

关于grails - 我无法使用 Geb 和 spock 运行简单的 Grails 功能测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8986124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com