2012-04-18 8 views
1

ここで誰もがgradle 1.0-mileestone-9でreportngを正常に設定しましたか?Selenium、TestNG、ReportNG with Gradleを使用

私は、Gradle(https://github.com/iainrose/page-objects)で開発されたSelenium 2 TestNGサンプルをダウンロードしました。それはうまく動作します(ブラウザを切り替えるためのbuild.gradleにSystem Propertiesを追加した後)、今はReportNGをミックスに追加したいと思います。私は、次のことを試してみました:

dependencies { 
compile "org.seleniumhq.selenium:selenium-java:2.15.0" 
compile "org.testng:testng:6.3.1" 
compile "org.uncommons:reportng:1.1.2" 
} 

それは次のエラーを生成します。

Could not resolve all dependencies for configuration ':compile'. 
> Artifact 'org.testng:testng:6.3.1:[email protected]' not found. 

私はhttp://issues.gradle.org/browse/GRADLE-2042で同様の問題を発見し、そこにコメントを追加しました、しかし、まだフォローがアップしていないです。依存関係からreportngを削除することが唯一の提案です...私はここで誰かがgradngを使ってreportngを取得する方法を知っていることを望んでいます。

の下Szpakによって提案されたコードを追加した後:

をSzpakにより示唆されるようにbuild.gradleするコードを追加した後、私は最終的にテストを実行することができます - まだreportngリスナーなしではなく場所に依存しては。しかし、かつて私はのように、リスナーにプラグイン:

useTestNG() { 
    options { 
     listeners << 'org.uncommons.reportng.HTMLReporter' 
     listeners << 'org.uncommons.reportng.JUnitXMLReporter' 
    } 

は、私がjava.lang.StackOverflowErrorを得た:何かが依存関係に問題があるように私の研究から

A problem occurred evaluating root project 'console-bg1'. 
> java.lang.StackOverflowError (no error message) 

* Exception is: 
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'console-bg1'. 
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54) 

(...) 

Caused by: java.lang.StackOverflowError 
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) 
at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:804) 
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1096) 
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049) 
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128) 
at org.gradle.api.tasks.testing.testng.TestNGOptions.methodMissing(TestNGOptions.groovy:204) 

オンラインに見えます。私はまだgradleでreportngを使用することができません...

答えて

0

回避策として、testng-5.0-jdk15 transitive依存関係をreportngパッケージから除外することができます。

dependencies { 
    compile "org.seleniumhq.selenium:selenium-java:2.15.0" 
    compile "org.testng:testng:6.3.1" 
    compile("org.uncommons:reportng:1.1.2") { 
     exclude group: "org.testng", module: "testng" 
    } 
    compile "com.google.inject:guice:3.0" 
} 

Btw、testCompileは、通常、テストの依存関係に適しています。

更新: "ClassNotFoundException:com.google.inject.Module"を避けるためにguiceの依存関係が追加されました。ここで

+0

セレンやTestNGのどちらもパッケージが、それ以上発見されたので、これは...、 – Lidia

+0

OKをコンパイルエラーの多くを引き起こし、私はその裏を取ります - コンパイルエラーからすべてのコンパイルエラーを投げ始めたのは、コンパイルからテストコンパイルに変わりました。いったん私がコンパイルし直したければ、あなたのコードは正常に機能しました。恐らく私は恐ろしい 'Artifact not found error'を取得しません。テストが実行されました。ありがとうございました! – Lidia

+0

reportngリスナーの追加後、java.lang.StackOverflowError例外を使用してビルドが失敗します。私の検索では、これが依存関係に関連しているように見えます(http://gradle.1045684.n5.nabble.com/StackOverflowError-in-idea-plugin-td3207809.htmlを参照)。私はこれがgradleの問題なのか、それとも依存宣言の何かが間違っているのかどうか判断できません。私は元の投稿の例外の一部になります。 – Lidia

0

はSzpakの貢献を含め、働いていたコードは次のとおりです。

dependencies { 
compile "org.seleniumhq.selenium:selenium-java:2.21.0" 
compile "org.testng:testng:6.3.1" 
compile group: 'com.google.inject', name: 'guice', version: '3.0' 
compile("org.uncommons:reportng:1.1.2") { 
    exclude group: "org.testng", module: "testng" 
    } 
} 
関連する問題