zbsz / robotest Goto Github PK
View Code? Open in Web Editor NEWRobolectric integration for ScalaTest
Robolectric integration for ScalaTest
Currently robotest works ok with robolectric 3.0, but not with 3.1:
java.lang.NoSuchMethodError: org.robolectric.internal.bytecode.InstrumentationConfiguration$Builder.doNotAquireClass(Ljava/lang/String;)Lorg/robolectric/internal/bytecode/InstrumentationConfiguration$Builder;
[info] at org.scalatest.RoboSuiteRunner.classLoaderConfig$lzycompute(RobolectricSuite.scala:140)
[info] at org.scalatest.RoboSuiteRunner.classLoaderConfig(RobolectricSuite.scala:138)
[info] at org.scalatest.RoboSuiteRunner.sdkEnvironment$lzycompute(RobolectricSuite.scala:149)
[info] at org.scalatest.RoboSuiteRunner.sdkEnvironment(RobolectricSuite.scala:148)
[info] at org.scalatest.RoboSuiteRunner.run(RobolectricSuite.scala:191)
[info] at org.scalatest.RobolectricSuite$class.run(RobolectricSuite.scala:41)
...
I'm confused, seems org.robolectric.internal.bycode.InstrumentationConfiguration$Builder does have method doNotAquireClass in robolectric 3.1, why NoSuchMethodError?
I'm unsure how to adapt to the changes in the library loading mechanism. I had been using project.properties to reference both local fs dependencies as well as exploded aars (android.support etc), which I manually placed in my project tree. You seem to be overriding robolectrics functionality completely by reading the target/aars
dir.
I'm sporting a multi-project structure with several inter-project root deps, and the aars
dir is only present in dep target dirs, not the test dir, which results in multiple problems.
First a NPE due to target/aars
being absent. Circumventing this with if (aarsDir.isDirectory)
, robolectric starts up but fails to find library resources.
Removing the findLibraries
override works fine, the old mechanism loads the resources as usual.
Am I missing something obvious? Seems to me it would work if we were trying to find aars in all target
dirs, but I assume this would be a sort of aggregation job for android-sdk-plugin
…though I'm perfectly fine with using the previously working method, in which case we would need a config flag for RobolectricSuite
to choose the library loading method.
Hi @zbsz,
this is probably not directly related to robotest, but when I try to test an Activity that is styled with an AppCompat theme I get this error
[info] Scenario: Start real activity *** FAILED ***
[info] java.lang.RuntimeException: Could not find any resource from reference ResName{org.robotest:style/Theme_AppCompat_NoActionBar} from style StyleData{name='AppTheme', parent='@style/Theme_AppCompat_NoActionBar'} with theme null
[info] at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getParent(ShadowAssetManager.java:517)
[info] at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getAttrValue(ShadowAssetManager.java:455)
I've created a reproducible test case here.
This issue seems to be known for Robolectric (here the most current issue for 3.0-SNAPSHOT).
It seems that the solution requires using a specialized RobolectricGradleTestRunner, but I'm admittedly not understanding the entire discussion.
I'm thankful for any hints on how to fix this and I'll happily create a PR once I've found a solution :)
Best
Martin
Thanks for the great library! I'm currently integrating it into macroid, but it still needs to support 2.10. It looks like you have crossScalaVersions
, but 2.10 artifact is not published. Would it be possible to publish it?
I can't manage to access the R
class in an aar project.
[error] ./robotest/example/src/test/scala/org.robotest/ResourcesSpec.scala:11: not found: value R
[error] Robolectric.application.getResources.getString(R.string.test_string) shouldEqual "test"
[error] ^
[error] one error found
[error] (test:compile) Compilation failed
[error] Total time: 8 s, completed 13.06.2015 19:27:48
To reproduce replace android.Plugin.androidBuild
in ./example/build.sbt
with android.Plugin.androidBuildAar
. Please note that I did only manage to test this on 0.7 with Robolectric 2.4.
Currently we are using libraries from aars
dir, but in some cases it is not enough.
Would be nice if we could obtain info about all library dependencies from sbt android plugin instead of relying on project.properties
file (this file was used in ant projects)
Example project: https://github.com/tek/robo_testcase_aarsdir
Hi,
could you update this to work with Robolectric 3.0-Snapshot?
Greetings
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.