如何使用gradle配置硒测试? [英] How to configure selenium tests with gradle?

查看:109
本文介绍了如何使用gradle配置硒测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用jboss上的gradle运行selenium测试,并且我能够进行必要的配置,并且希望与社区分享。

解决方案

解决方案如下:
$ b

gradle.build:

  apply plugin:'java'
apply plugin:'eclipse-wtp'
apply plugin:'war'
apply plugin:'findbugs '
//申请:'http://github.com/breskeby/gradleplugins/raw/master/emmaPlugin/emma.gradle'
申请:'emma.gradle'
buildDir ='build'
$ b $ sourceCompatibility = 1.7
version =''

buildscript {
repositories {
mavenCentral()
}

依赖项{
classpath'org.gradle.api.plugins:gradle-cargo-plugin:0.6'
}
}

存储库{
mavenCentral()
mavenRepo url:'http://repository.primefaces.org'
mavenRepo url:'htt p://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'
}


配置{
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
}
}

依赖项{
// JSF
编译组:'com.sun.faces',名称:'jsf-api',版本:'2.1.22'
编译组:'com.sun.faces',名称:'jsf-impl',版本:'2.1.22'
编译'org.ocpsoft.rewrite:rewrite-servlet:2.0.3.Final'
compile'org.ocpsoft.rewrite:rewrite-config-prettyfaces:2.0.3.Final'


// Servlet
编译组:'javax.servlet',名称:'jstl',版本:'1.2'
providesCompile组:'org.jboss.spec',名称:'jboss- javaee-6.0',版本:'1.0.0.Final'
编译'taglibs:standard:1.1.2'
编译组:'org.springframework',名称:'spring-web',版本:'3.2.2.RELEASE'

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

// Prime Faces
编译group:'org.primefaces',name:'primefaces',版本:'4.0-SNAPSHOT'
compile'org.primefaces.themes:bootstrap:1.0.10'

// DB
编译组:'org.springframework.data ,name:'spring-data-jpa',版本:'1.3.1.RELEASE'
编译组:'org.springframework',名称:'spring-aspects',版本:'3.2.2.RELEASE'
编译组:'mysql',名称:'mysql-connector-java',版本:'5.1.9'

编译组:'javax.inject',名称:'javax。注入',版本:'1'
编译组:'javax.enterprise',名称:'cdi-api',版本:'1.0-SP4'
编译'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'
编译'org.springframew ork.security:spring-security-web:3.1.4.RELEASE'
compile'org.springframework.security:spring-security-config:3.1.4.RELEASE'

// Utility
compile'c​​om.google.guava:guava:14.0.1'
compile'c​​ommons-lang:commons-lang:2.6'
compile'org.apache.commons:commons-email :1.3.1'
compile'c​​om.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'


//小胡子模板
编译'com.github.jknack:handlebars:1.0.0 '

//项目
//编译项目(:ExtraValidators)

////测试相关性
testCompile'c​​om.googlecode。 jmockit:jmockit:1.2'
testCompile组:'junit',name:'junit ,版本:'4.11'
testCompile'c​​om.h2database:h2:1.3.172'

// Spring测试
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'

/ *远程Jboss * /
testCompile组:'org.jboss.arquillian',名称:'arquillian-junit',版本:'1.0.0-SNAPSHOT '
jbossasRemoteTestRuntime组:'org.jboss.arquillian.container',名称:'arquillian-jbossas-remote-6',版本:'1.0.0-SNAPSHOT'
jbossasRemoteTestRuntime组:'org.jboss .jbossas',名称:'jboss-as-server',分类器:'client',版本:'6.1.0.Final',传递:false
jboss asRemoteTestRuntime组:'org.jboss.jbossas',名称:'jboss-as-profileservice',分类器:'client',版本:'6.1.0.Final'
}


任务包装器(类型:包装器){
gradleVersion ='1.6'
}

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


任务硒(类型:Test){
testClassesDir = sourceSets.selenium.output。 classesDir
classpath = sourceSets.selenium.runtimeClasspath + files('src / selenium / resources-jbossas')+ configurations.jbossasRemoteTestRuntime
}

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

i want to run selenium tests with gradle on jboss, and i was able to make the required configuration and i want to share it with the community.

解决方案

Solution is as follows:

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
}

you need to start jboss server manually then use the command gradlew clean selenium

这篇关于如何使用gradle配置硒测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆