Giter Club home page Giter Club logo

robospock's Issues

License?

What license is robospock released under? ASL 2.0? GPL?

GradleBasedAndroidApplication: gradlew test does not work

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.

"gradlew test" fails on Windows when normalizing paths

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'.

Cannot invoke method getAllDependencies() on null object

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'

Roboguice test module

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()))

Groovy plugin incompatible with android plugin

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

Run tests from cli

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 :)

test onCreate but setup activity's field before

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...
}

Can't run a single spec with gradle?

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.

GradleRoboSpecification fails to load project resources

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?

Bump spock version

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

AntBasedAndroidApplication won't build on Windows

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

Version of Robolectric

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

Annotation order affects test class

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.

Error:Class com.android.build.gradle.internal.scope.VariantScopeImpl does not implement the requested interface com.android.build.gradle.internal.scope.BaseScope

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

Specification only read @Config annotation on its own, not including parent class

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.

Upgrade com.android.support dependency

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 ?

FYI: New robospock plugin for Gradle

For your information:

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 =)

New to RoboSpock

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

Still using RoboGuice?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.