当前位置: 首页 > 面试题库 >

如何使用Gradle配置selenium测试?

颜祖鹤
2023-03-14
问题内容

我想在jboss上使用gradle进行selenium测试,并且能够进行所需的配置,并且希望与社区共享。


问题答案:

解决方法如下:

gradle.build:

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
apply plugin: 'findbugs'
//apply from:'http://github.com/breskeby/gradleplugins/raw/master/emmaPlugin/emma.gradle'
apply from: 'emma.gradle'
buildDir = 'build'

sourceCompatibility = 1.7
version = ''

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6'
    }
}

repositories {
    mavenCentral()
    mavenRepo url: 'http://repository.primefaces.org'
    mavenRepo url: 'http://repository.jboss.org/nexus/content/groups/public'
    mavenRepo url: 'http://repository.jboss.org/maven2'
    mavenRepo url: 'http://maven.springframework.org/release'
    mavenRepo url: 'http://repo1.maven.org/maven2'
    mavenRepo url: 'http://git.solutionstream.com/nexus/content/repositories/thirdparty'
}


configurations {
   compileOnly
   weldEmbeddedTestRuntime { extendsFrom testRuntime }
   jbossasRemoteTestRuntime { extendsFrom testRuntime, compileOnly }
}

sourceSets {

   main {
      compileClasspath = configurations.compile + configurations.compileOnly
   }

   test {
      compileClasspath = compileClasspath + configurations.compileOnly
   }

   selenium {
      compileClasspath = compileClasspath + configurations.compileOnly
   }
}

dependencies {
    //JSF
    compile group: 'com.sun.faces', name: 'jsf-api', version: '2.1.22'
    compile group: 'com.sun.faces', name: 'jsf-impl', version: '2.1.22'
    compile 'org.ocpsoft.rewrite:rewrite-servlet:2.0.3.Final'
    compile 'org.ocpsoft.rewrite:rewrite-config-prettyfaces:2.0.3.Final'


    //Servlet
    compile group: 'javax.servlet', name: 'jstl', version: '1.2'
    providedCompile group: 'org.jboss.spec', name: 'jboss-javaee-6.0', version: '1.0.0.Final'
    compile 'taglibs:standard:1.1.2'
    compile group: 'org.springframework', name: 'spring-web', version: '3.2.2.RELEASE'

    //Omnifaces
    compile 'org.omnifaces:omnifaces:1.5'

    //Prime Faces
    compile group: 'org.primefaces', name: 'primefaces', version: '4.0-SNAPSHOT'
    compile 'org.primefaces.themes:bootstrap:1.0.10'

    // DB
    compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.3.1.RELEASE'
    compile group: 'org.springframework', name: 'spring-aspects', version: '3.2.2.RELEASE'
    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.9'

    compile group: 'javax.inject', name: 'javax.inject', version: '1'
    compile group: 'javax.enterprise', name: 'cdi-api', version: '1.0-SP4'
    compile 'cglib:cglib-nodep:2.2.2'

    //Hibernate / JPA   
    compile 'org.hibernate:hibernate-core:4.1.0.Final'
    compile 'org.hibernate:hibernate-entitymanager:4.1.0.Final'
    compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
    //JSR-303
    compile 'org.hibernate:hibernate-validator:4.3.1.Final'

    // Spring Security
    compile 'org.springframework.security:spring-security-core:3.1.4.RELEASE'
    compile 'org.springframework.security:spring-security-web:3.1.4.RELEASE'
    compile 'org.springframework.security:spring-security-config:3.1.4.RELEASE'

    //Utility
    compile 'com.google.guava:guava:14.0.1'
    compile 'commons-lang:commons-lang:2.6'
    compile 'org.apache.commons:commons-email:1.3.1'
    compile 'com.typesafe:config:1.0.0'
    compile 'joda-time:joda-time:2.2'
    compile 'org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:1.8.3'
    compile 'org.slf4j:slf4j-api:1.7.2'
    compile 'org.slf4j:jcl-over-slf4j:1.7.2'
    compile 'org.slf4j:slf4j-log4j12:1.7.2'


    //Mustache Templates
    compile 'com.github.jknack:handlebars:1.0.0'

    //Projects
    //compile project(":ExtraValidators")

    ////TESTING DEPENDENCIES
    testCompile 'com.googlecode.jmockit:jmockit:1.2'
    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile 'com.h2database:h2:1.3.172'

    //Spring Testing
    testCompile 'org.springframework:spring-test:3.2.3.RELEASE'

    /* Selenium */
    seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.33.0'
    seleniumCompile 'junit:junit:4.11'
    seleniumCompile 'org.slf4j:slf4j-api:1.7.2'
    seleniumCompile 'org.slf4j:slf4j-log4j12:1.7.2'
    seleniumCompile 'org.slf4j:jcl-over-slf4j:1.7.2'

    /* Remote Jboss */
    testCompile group: 'org.jboss.arquillian', name: 'arquillian-junit', version: '1.0.0-SNAPSHOT'   
    jbossasRemoteTestRuntime group: 'org.jboss.arquillian.container', name: 'arquillian-jbossas-remote-6', version: '1.0.0-SNAPSHOT'
    jbossasRemoteTestRuntime group: 'org.jboss.jbossas', name: 'jboss-as-server', classifier: 'client', version: '6.1.0.Final', transitive: false
    jbossasRemoteTestRuntime group: 'org.jboss.jbossas', name: 'jboss-as-profileservice', classifier: 'client', version: '6.1.0.Final'
}


task wrapper(type: Wrapper){
    gradleVersion = '1.6'
}

eclipse {
    classpath {
       downloadSources=true
       plusConfigurations += configurations.seleniumCompile
    }
}


task selenium(type: Test) {
   testClassesDir = sourceSets.selenium.output.classesDir
   classpath = sourceSets.selenium.runtimeClasspath  + files('src/selenium/resources-jbossas') + configurations.jbossasRemoteTestRuntime
}

您需要手动启动jboss服务器,然后使用命令 gradlew clean selenium



 类似资料:
  • 如https://cloud . Google . com/app engine/docs/standard/Java/tools/Gradle-reference上所述,AppEngine Gradle插件提供如下配置: 使用 时,这样的配置应该是什么样子? 我正在查看AppEngine任务,但不明白如何将其连接到适当的Kotlin DSL设置。 编辑 当简单地将上述块添加到<code>buil

  • 使用Gradle 4.4.1和静态编程语言-DSL,我想在我的静态编程语言1.2.20项目中配置实验性的静态编程语言协程。这被证明是出奇困难的。 官方静态编程语言留档本身只提到Groovy DSL的Gradle,而不是静态编程语言。 Kotlin DSL项目有一个不起作用的协同路由示例。可能是针对较旧的Gradle版本(该脚本中的Kotlin版本为1.1.51,这本身就是可疑的)。 PS:甚至In

  • 问题内容: 在maven中,我可以为依赖关系解析指定“类型”。我正试图拉下一个。如何使用Gradle做到这一点? 我已经尝试过使用下面的Gradle Dependency,但这并没有降低。 Maven依赖关系: 详细信息: Gradle 1.7 我正在尝试从 Maven Central 下拉“ hbase-0.94.2-tests.jar” 问题答案: Gradle没有Maven的直接等效项,但应

  • 问题内容: 目前,我有以下 build.gradle 文件: 这 的build.gradle 文件是我的仓库 在这里 。我所有的主文件都在 src / model /中 ,它们各自的测试在 test / model中 。 如何正确添加JUnit 4 依赖项 ,然后在 测试/模型 文件夹中运行那些测试? 问题答案: 如何正确添加junit 4依赖关系? 假设您要针对标准Maven(或等效版本)存储库

  • 我有一个服务器,用Java编写的,那是我的应用程序,我想在上面运行一些测试。我正在使用gradle来管理依赖项和构建任务等,所以我也想在这方面使用它。我需要启动服务器,然后运行我的单元测试,这会对它发出一堆HTTP请求,然后在测试完成后,理想情况下甚至关闭服务器。所以我尝试在build.gradle中添加(jettyRunWar是运行服务器的工具),但我想这太简单了,因为从不从jettyRunWa

  • 当前我有以下build.gradle文件: 此build.gradle文件用于我的存储库。我的所有主文件都在src/model/中,它们各自的测试都在test/model中。