2017-09-20 10 views
2

Androidスタジオ3.0ベータ6とgradle 3.4.1で動作する新しいRobospock仕様を取得できません。私は、Android Studioでテストを実行したときに私が得るエラーは次のとおりです。 Android Studio 3.0でRobospock initializationError NoSuchMethodError

import org.robolectric.annotation.Config 
import org.robospock.RoboSpecification 
@Config(constants = com.myapp.BuildConfig, sdk = 19, manifest='src/main/AndroidManifest.xml') 
public class MyActivitySpec extends RoboSpecification { 
    ... 
} 

マイGradleの依存関係

は次のとおりです:

testImplementation 'org.robolectric:robolectric:3.4.2' 
testImplementation('org.robospock:robospock:1.0.1') { 
    exclude module: 'robolectric' 
} 

以上がすべてに変換

java.lang.NoSuchMethodError: org.robolectric.annotation.Config$Implementation.<init>(Lorg/robolectric/annotation/Config;)V 

    at org.robospock.internal.RoboSputnik.<clinit>(RoboSputnik.java:52) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104) 
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86) 
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) 
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26) 
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) 
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49) 
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) 
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) 
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) 

仕様は次のようになりますrobolectric推移的依存性(非常に大きい)と以下のrobospock依存性:

私は次のエラーを取得する。この場合 @RunWith(MyTestRunner)

java.lang.Exception: No runnable methods 

    at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191) 
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128) 
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:416) 
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84) 
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65) 
    at org.robolectric.internal.SandboxTestRunner.<init>(SandboxTestRunner.java:43) 
    at org.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:77) 

public class MyTestRunner extends RobolectricTestRunner { 

    public MyTestRunner(final Class<?> testClass) throws InitializationError { 
     super(testClass) 
    } 

    @Override protected Config buildGlobalConfig() { 
     return new Config.Builder().setApplication(com.me.MyApp).setConstants(com.myapp.BuildConfig).setSdk(19).setManifest('src/main/AndroidManifest.xml').build(); 
    } 
} 
を、クラスのアノテーションを使用して、私の仕様でそれを指定:0

は、私はまた、次のようにカスタムランナーを作成しようとしました

Androidスタジオでの実行設定が重要な場合は、Android Junit設定です。

TIA任意のガイダンスです。

答えて

3

Robospockは、現在、ほぼ一年のために更新されませんでしたので、私の最高の推測では、それはあなたが提供Robolectricバージョンと互換性がありませんです。

testImplementation 'org.robolectric:robolectric:3.4.2' 
testImplementation('org.robospock:robospock:1.0.1') { 
    exclude module: 'robolectric' 
} 

は、手動で1が3.0あるライブラリでサポートされていることを、別のバージョンを選択しました。それは、ライブラリの更新が必要となる固定 https://github.com/robolectric/robolectric/blob/master/annotations/src/main/java/org/robolectric/annotation/Config.java#L175

エラーがマスター上で不足しているConfig$Implementationコンストラクタを、行方不明についてです。

+0

あなたは私の英雄です。 Robolectric 3.4.1をカスタムランナーで動作させることはできますか?もしそうなら、私が列挙した "No runnable methods"問題を修正する方法に関する提案はありますか? –

+0

@FarrukhNajmi私は、内部的に与えられたコンストラクタを呼び出すので、ライブラリを更新する必要があると思います。 –

1

try ElectricSpock。 Robolectricと連携したRoboSpockに基づく私のプロジェクトです。

+0

ElectricSpockプロジェクトでrobolectricテストを実行することができません。私は次の例外を受け取ります。 Android Studio 3.0ベータ6でRobolectric 3.4.2を動作させる方法を教えてください。 このようなマニフェストファイルはありません:build \ intermediates \ manifests \ full \ debug \ - デフォルト android.content.res.Resources $のNotFoundException:リソースID番号の0x7f08005c android.content.res.Resources.getValue(Resources.java:1013)で \t android.support.v7.widget.AppCompatDrawableManagerで \t。loadDrawableFromDelegates(AppCompatDrawableManager –

+0

テストコードを投稿しますか?そこに問題を提出して追跡できるようにすればいいです。 https://github.com/hkhc/electricspock/issues – thinkpanda

関連する問題