gpt4 book ai didi

groovy - 由于缺少依赖项 org/spockframework/mock/MockController,无法加载类 get.spock.GebSpec

转载 作者:行者123 更新时间:2023-12-05 07:44:52 25 4
gpt4 key购买 nike

我的测试框架有什么问题,我无法运行我的测试?

我的build.gradle

version '1.0-SNAPSHOT'
//task wrapper(type: Wrapper) {
// gebVersion = '0.13.1'
// seleniumVersion = '2.52.0'
//
// distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
//}


apply plugin: 'groovy'

repositories {
mavenCentral()
}

sourceCompatibility = 1.5

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
// geb
compile 'org.codehaus.geb:geb-core:0.7.2'
compile 'org.codehaus.geb:geb-spock:0.7.2'
compile "org.seleniumhq.selenium:selenium-firefox-driver:2.52.0"
compile "org.seleniumhq.selenium:selenium-chrome-driver:2.52.0"
compile "org.seleniumhq.selenium:selenium-safari-driver:2.52.0"
compile "org.seleniumhq.selenium:selenium-support:2.52.0"
// spock
compile "org.codehaus.groovy:groovy-all:2.4.1"
testCompile "org.spockframework:spock-core:1.0-groovy-2.4"
}

我的GebConfig.groovy

    //import geb.driver.SauceLabsDriverFactory
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.safari.SafariDriver

//baseUrl = 'http://madison.craigslist.org'

// default driver...
System.setProperty('webdriver.chrome.driver', "../resources/chromedriver")
driver = {new ChromeDriver()}

environments {

'chrome' {
def chromeDriver = new File('src/test/resources/chromedriver') // add .exe for Windows...
System.setProperty('webdriver.chrome.driver', chromeDriver.absolutePath)
driver = { new ChromeDriver() }
}

// 'ff' {
// driver = { new FirefoxDriver() }
// driver.manage().window().maximize()
// }

'safari' {
driver = { new SafariDriver() }
}
}

waiting {
timeout = 6
retryInterval = 0.5
slow { timeout = 12 }
reallySlow { timeout = 24 }
}

reportsDir = "geb-reports"

页面类

    package pages

import geb.Page
import geb.Browser

class LoginPage extends Page{

static url = "https://qmdev.quickblox.com"
// static at = {heading.isDisplayed()}
static at = {title == "Q-municate"}

static content = {
heading {$("div#l-welcome_block l-welcome_text_description")}
logInByEmailOrSocial {$("button", text:"login by email or social")}
logInPageTitle {$("div.l-welcome_block l-welcome_text_login")}
}
}

测试类

import geb.spock.GebReportingSpec
import pages.LoginPage
import spock.lang.*
import geb.spock.GebSpec


@Stepwise
class LoginPageTest extends GebReportingSpec{

def "log in Q-municate"(){
given: "Open Log In page"
to LoginPage

when: "chose log in by email"
LoginPage.logInByEmailOrSocial.click()

then: "Ensure that we are on LogIn page"
LoginPage.logInPageTitle.text() == "Log In"
}
}

关于我的框架:我使用 web-spock-groovy-gradle bundle 来实现 Web UI 自动化,我是 Gradle 的新用户。请告诉我,我的 build.gradle 和 GebConfig.groovy 有什么问题。

最佳答案

您的 Geb-Spock 版本 0.7.2 很旧,可能是导致您出现问题的原因。我建议将这两个依赖项更改为 1.1.1 版:

compile 'org.codehaus.geb:geb-core:0.7.2'  //change to 1.1.1
compile 'org.codehaus.geb:geb-spock:0.7.2' //change to 1.1.1

此外,我检查了 Spock API 版本 1.1 中的“org/spockframework/mock/MockController”,它似乎不存在。

enter image description here

( http://spockframework.org/spock/javadoc/1.1-SNAPSHOT/index.html )正如您在这张图片中看到的,只有 2 个类是 spock.mock 包的一部分,而 MockController 不是其中之一。尝试更新您的 geb 版本,如果有帮助请告诉我们

关于groovy - 由于缺少依赖项 org/spockframework/mock/MockController,无法加载类 get.spock.GebSpec,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42485635/

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