免责声明:在我来这里问这个问题之前,我已经通过了这么多不同的来源。我用maven引用了geb的GitHub项目、geb的book和许多YouTube教程,等等。
我只是试图让一个项目启动和运行,做一个非常简单的自动化搜索引擎测试,只是为了让我可以玩工具。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nope</groupId>
<artifactId>nope</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>testing this</name>
<description>testing this</description>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.spockframework/spock-core -->
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.1-groovy-2.4</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.gebish/geb-spock -->
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-spock</artifactId>
<version>2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.9.1</version>
</dependency>
</dependencies>
</project>
package com.na.tests
import spock.lang.Specification
import geb.*
class MyBaseTests extends Specification {
def "search 'Groovy Browser Automation' in duckduckgo"() {
given: "we are on the duckduckgo search-engine"
go "http://duckduckgo.com"
when: "we search for 'Groovy Browser Automation'"
$("#search_form_homepage").q = "Groovy Browser Automation"
$("#search_button_homepage").click()
then: "the first result is the geb website"
assert $("#links").find(".links_main a", 0).attr("href") == "http://www.gebish.org/"
}
}
这是我在测试中得到的例外。我运行了一个非常简单的assert Hello World测试,该测试已经通过,为了清晰起见,我删除了该测试:
groovy.lang.missingMethodException:方法:com.na.tests.mybasetests.go()的签名不适用于参数类型:(java.lang.string)值:[http://duckduckgo.com]可能的解决方案:is(java.lang.object)、Mock()、Spy()、any()、grep()、Mock(groovy.lang.closure)在com.na.tests.mybasetests.search中的'groovy浏览器自动化‘在duckduckgo(Mybasetests.groovy:22)
编辑
值得注意的是,在我的IDE(Eclipse)中,似乎有些关键字要么不被识别,要么不是合法的(即:go“http://duckduckgo.com”)。让我觉得我没有配置什么东西。
如果要使用GEB,您需要扩展geb.spock.gebspec
,而不是specification
。另见gebish.org/manual/current/#spock-junit-testng
我们有以下情况:我们有单元测试和集成测试。单元测试类以结束,集成测试以结束。为了在Maven build中只执行单元测试,我们使用以下配置:
主要内容:m2eclipse,在 Eclipse 中配置 Maven,修改本地仓库位置,在 Eclipse 中使用 Maven前面所涉及的 Maven 项目结构和代码都十分的简单,即使是使用最简单的文本编辑器也能够很快就能完成。但在实际的开发过程中,我们所涉及的 Maven 项目往往要复杂得多,此时我们就需要借助 IDE(集成开发环境) 来帮助我们完成开发工作。 当今最流行的 Java IDE 主要有 2 种:Eclipse 和 IntelliJ IDEA,其中 eclipse 是完全免费的,用
Mark问这是什么样子的,下面是这段代码。 pom和Checkstyle配置文件都正常工作,但 如果它是Treewalker的子文件,我会从Maven插件得到错误,但不能从Eclipse插件得到错误,不过,我只能让它与Eclipse插件一起工作。
本文向大家介绍Eclipse中maven的配置详解,包括了Eclipse中maven的配置详解的使用技巧和注意事项,需要的朋友参考一下 1. 需要准备:apache-maven-3.2.3.zip包 Repository.rar本地仓库 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持呐喊教程。
1. 官网下载maven并解压 2. 电脑需搭建java环境,安装JDK1.7+版本 3. 创建MAVEN_HOME环境变量 4. 将%MAVEN_HOME%/bin加入环境变量path 5. cmd输入mvn -v检查是否安装成功 6. 配置本地仓库、maven下conf文件夹下的setting文件 (红色下画线就是你本地仓库地址,红色打钩的就是你默认的地址) 查看d盘下是否生成,如未生成执行
我在Windows上安装了Maven并配置了环境。测试并验证Maven是否正确安装。 在Eclipse中,我正确地安装了m2e。转到Eclipse安装细节,我可以看到m2e,最新构建。 我创建了一个pom文件,包括以下依赖项,一个是针对jbehave,另一个是JUnit。 我创建了一个java类,需要从和导入类,可以看出,这两个类都无法解析。 转到Eclipse构建路径,我添加了jbehave-c