robospock / robospock Goto Github PK
View Code? Open in Web Editor NEWA testing framework which brings powers of Spock and Groovy to Android app testing
Home Page: http://robospock.org
License: MIT License
A testing framework which brings powers of Spock and Groovy to Android app testing
Home Page: http://robospock.org
License: MIT License
Moved from
#33
When I click on the http://robospock.org link on the Github project page, I get a domain parking page not the Robospock website.
Keep getting this error when I try and use the robospock plugin in my test project. I've pretty much used the example build file with a dependency to my main project. Am I missing something obvious here?
What license is robospock released under? ASL 2.0? GPL?
On OS X,
RoboSpock/applications/GradleBasedAndroidApplication $ ../../gradlew test
...
* What went wrong:
Could not determine the dependencies of task ':gradleApp-robospock-tests:testDebug'.
> Configuration with name 'default' not found.
Doing gradlew test
on a cloned repo, on Windows, fails with this message
Execution failed for task ':gradleApp-robospock-tests:testDebug'.
> Could not normalize path for file 'C:\android-sdk\platforms\android-15\android.jar;C:\android-sdk\tools\support\annotations.jar'.
What are the current plans to support robolectric 4.3 (current latest release)?
With Robolectric 3.0 comes a new RobolectricGradleTestRunner and we could move bits from it to RoboSputnik so that there is no need to add @config annotations to all Specs so that AndroidManifest.xml file is visible to Robolectric.
First, there is now a robospock tag at Stackoverflow (http://stackoverflow.com/questions/tagged/robospock). And my question is probably more appropriate for there. But since noone knows about it yet...
I started with 2 modules, one for my app and one for my tests, per your Gradle example. But the test module wouldn't compile because it wasn't picking up the transient jar dependencies. So I ended up creating a 3rd module with just my jars and told the other projects to depend on that project.
But now I'm getting the following error:
* Where:
Build file '/Users/bradrhoads/Documents/src/estante/src/robospocktests/build.gradle' line: 52
* What went wrong:
A problem occurred evaluating project ':estanteApp-robospock-tests'.
> Cannot invoke method getAllDependencies() on null object
The debug shows:
09:52:04.954 [DEBUG] [org.gradle.api.internal.artifacts.mvnsettings.DefaultLocalMavenRepositoryLocator] No local repository in Settings file defined. Using default path: /Users/bradrhoads/.m2/repository
09:52:06.480 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 5.673 secs
09:52:06.566 [ERROR] [org.gradle.BuildExceptionReporter]
09:52:06.615 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
09:52:06.632 [ERROR] [org.gradle.BuildExceptionReporter]
09:52:06.632 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
09:52:06.632 [ERROR] [org.gradle.BuildExceptionReporter] Build file '/Users/bradrhoads/Documents/src/estante/src/robospocktests/build.gradle' line: 52
09:52:06.633 [ERROR] [org.gradle.BuildExceptionReporter]
09:52:06.633 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
09:52:06.633 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating project ':estanteApp-robospock-tests'.
09:52:06.633 [ERROR] [org.gradle.BuildExceptionReporter] > Cannot invoke method getAllDependencies() on null object
09:52:06.663 [ERROR] [org.gradle.BuildExceptionReporter]
09:52:06.663 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
09:52:06.664 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.GradleScriptException: A problem occurred evaluating project ':estanteApp-robospock-tests'.
09:52:06.664 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
09:5
Here's my build.gradle for the test project:
buildscript {
repositories {
// mavenLocal()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'org.robospock:robospock-plugin:0.4.0'
}
}
repositories {
mavenLocal()
mavenCentral()
}
apply plugin: 'groovy'
dependencies {
testCompile "org.codehaus.groovy:groovy-all:1.8.6"
testCompile 'org.robospock:robospock:0.4.4'
//compile fileTree(dir: ':android:libs', include: '*.jar')
testCompile project(':shared-jars')
testCompile project(':estanteApp')
}
//sourceSets.test.java.srcDirs = ['../android/src/', '../android/build/source/r/debug']
test {
testLogging {
lifecycle {
exceptionFormat "full"
}
}
}
project.ext {
robospock = ":estanteApp" // project to test
}
//tasks["test"].dependsOn //project(":estanteApp").tasks["compileDebugJava"]
apply plugin: 'robospock'
Is it possible to override the Roboguice default modules with a test module with robospock? I've tried something like the following, but it seems that my test module is applied, however all other bindings are lost..
RoboGuice.setBaseApplicationInjector(
Robolectric.application,
RoboGuice.DEFAULT_STAGE,
Modules.override(defaultModule).with(new MyTestModule()))
Since the groovy plugin extends from the java plugin, I'm receiving the following error:
The 'java' plugin has been applied, but it is not compatible with the Android plugins.
Consult IDE log for more details (Help | Show Log)
I don't know how this can work for you guys
Any interest in bumping this? Currently I cannot set SDK to 24.
Ref: https://github.com/robolectric/robolectric/releases/tag/robolectric-3.1
Btw, we're using robospock, thx for your amazing work!
Are there any plans to upgrade Robolectric to 3.0?
While migrating to new Robolectric, we lost RoboGuice support.
Reenable it.
RoboElectric is now at version 2.1
It'd be great to be able to use the latest version.
i want use robospock in Eclipse, any sample or sugesstion?
Hi, I've been using robospock with android studio and it's working quite well. I can run my tests from the IDE with no problems. However, I'm now attempting to set up a CI server, and I'm having difficulty executing the tests from command line.
When running ./gradlew clean assemble test
I can see the test tasks are being executed, but my tests are not actually running. The build always succeeds even when I add tests that should always fail:
public class FailureTest extends Specification {
def "Failing Test"() {
expect:
false
}
}
I expect I'm just missing something simple like a config option. Any help would be appreciated :)
My NoteView activity in onCreate uses a helper class. I want to test that it calls the helper class correctly. How do I write a robospock test for it? My best shot is:
def "should ..."() {
when:
def bundle = new Bundle().putLong(NotesDbAdapter.KEY_ROWID,11)
def dbHelper = Mock(INotesDbAdapter);
// Need to call this before onCreate() is called: activity.setDatabaseHelper(dbHelper)
def activity = Robolectric.buildActivity(NoteView).create(bundle).get()
then:
... I check here that the dbHelper was called correctly...
}
We use heavily modified getConfig method and it seems that one provided by Robolectric has some features we don't support.
Most probably we can just use the original method from Robolectric 3.0
This is pretty intermittent, is anyone else running into the same issues?
I sent a pull request for travis-ci.
If you want to use it, merge my pull request.
Thank you
So I've tried ./gradlew -Dtest.single=SomeSpec and it runs all the tests.
I've also tried ./gradlew -DtestSomeVarient=SomeSpec, as well as ./gradlew -Dtest.com.some.package.SomeSpec (and the various combinations of these 2 approaches) and still no ๐ฒ
Any ideas? I have a feeling I got this working about a year ago but there's no docs that help.
Hi,
I have tested 0.7 and 1.0 version and the same issue occurs. When I am using GradleRoboSpecification only Android system resources are loaded and ResourceNotFound error is raised during tests. I have fixed this issue by falling back to RoboSpecification with manifest path specified (standard location). After upgrading to 1.0 I saw RoboSpecification is Deprecated. I do not know what is causing the issue, a hint is that I have multimodule project with both java and android libraries.
Any ideas what is causing this issue?
Right now RoboSpock uses spock-0.7 and version 1.0 is out there.
RoboSpockIntereceptor might need to be adjusted to work with new spock
Building AntBasedAndroidApplication
fails to lauch android
and ant
. If I modify the commandLine value it works (but obviously breaks on non-Windows)
- commandLine 'android', 'update', 'project', '-p', '.'
+ commandLine 'cmd', '/c', 'android', 'update', 'project', '-p', '.'
and
- commandLine 'ant', 'debug'
+ commandLine 'cmd', '/c', 'ant', 'debug'
Unfortunately, I don't know if there is a gradle idiom to handle platform dependent variables, so I cannot supply a fix http://stackoverflow.com/questions/11235614/how-to-detect-the-current-os-from-gradle
Hi I know that is not the place where I should ask this kind of question but what version of Robolectric is used in RoboSpock? Is the version updated frequently? Thanks
This combination works:
@UseShadows([...])
@RobolectricGuiceModules([...])
@RunWith(RoboSputnik)
RoboSputnik class has to stay but other annotations should not be obligatory, nor their args.
What's more their order affects the runner.
I'd like to be able to include RoboSpock as a dependency in my gradle.build. Is it available anywhere?
Thanks for the great tool!
couldn't find docs in the website
If the android gradle plugin is updated to 2.2.0-alpha5, we're start getting the following error while syncing gradle files:
Error:Class com.android.build.gradle.internal.scope.VariantScopeImpl does not implement the requested interface com.android.build.gradle.internal.scope.BaseScope
If we comment out the plugin, it will work.
classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.10' apply plugin: 'groovyx.grooid.groovy-android'
I've gisted a logfile with the corresponding error messages: https://gist.github.com/henriquedesousa/61fe25cb273637eacaaef2fa27532abb
Usually I would use a base test class to carry all setups and cleanups, like:
@Config(sdk = 21, constants = BuildConfig, manifest = "app/src/main/AndroidManifest.xml", application = App.class)
class BaseRobolectricSpec extends GradleRoboSpecification {
def app = (App) RuntimeEnvironment.application;
}
But it throws "No 'constants' field in @config annotation!" exception when I put @config on the base test class insteads of specify specification, so I should copy the same @config annotation everywhere.
Hi:
First of all, congratulations, it's nice to see unit testing with Spock on Android. Good work.
I think the latest android support library is 22.0.1 and even the Android Studio is now complaining saying the 19.x.x is too old to be used.
Do you have any plans to upgrade the android support dependency any time soon ?
I've created a new Gradle plugin for robospock which actually works and makes life ridiculously simple...
Here it is: https://github.com/Centril/gradle-plugin-robospock
You can apply it in a host of different ways, but the most simple is:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'se.centril.robospock:gradle-plugin-robospock:0.2.0'
}
}
['android-sdk-manager', 'com.android.application', 'robospock']
.each { apply plugin: it }
android {
buildTypes {
defaultConfig {
minSdkVersion 9
targetSdkVersion 20
}
}
compileSdkVersion 20
buildToolsVersion "20"
// more exciting stuff...
}
Then you can put all your testing classes in {android-project-root}/src/test/
.
Thats it =)
Hello!
My name is Kuba and I'm learning about bdd with android.
I'm trying to make a simple app, but I really don't know much about testing - which is the main point.
So how do I create tests and run them?
I know you've got samples, but are there any tutorials?
Best Regards
Hi.
I am really desperate to setup robospock. But I cannot get my project setup to work. Please check this stackoverflow post and my github example project.
http://stackoverflow.com/questions/25971126/need-help-setting-up-robospock
You made sample applications for Ant and Gradle based applications.
Please support (or document) usage of RoboSpock with Maven-based Android apps.
Hello,
your documentation states that the framework makes use of RoboGuice. However, RoboGuice has been retired for two years. Is that true, or am I misunderstanding something?
Thank you,
Igor
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.