AndrewReitz / android-spock

Running Spock on Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can this execute espresso / robotium tests?

mg6maciej opened this issue · comments

Hey,
This is more of a question then issue, but I'm wondering if I can use your runner for functional testing?
Cheers,
Maciej

In theory you could write them the same way as you normally would, using an AndroidTestCase, but I have not tried. I've only tested using regular Spock tests. I'm in the process of figuring out how load in activities and the application like the standard android test framework.

Thanks for quick reply. I'll try to connect them together and report back if I have any success.

Why did you bundle android test support framework in your lib? Do you use some newer or older version of it and not 0.1 like Espresso?

I had to do a workaround like this

androidTestCompile('com.android.support.test.espresso:espresso-core:2.0') {
    exclude group: 'com.android.support.test', module: 'testing-support-lib'
}

to make it compile and run tests.
Example spock tests run nicely. Thanks!

In short I needed to get access to some of the package protected stuff to
make this work. If you can find me the tag to 0.1 I will switch to it. That
will make a lot of other work significantly easier. This issue will be
resolved with some updates to the Spock framework soon, but I would still
like to use 0.1 for other pieces of this library.

On Thu, Jan 29, 2015, 2:35 PM Maciej Górski notifications@github.com
wrote:

Why did you bundle android test support framework in your lib? Do you use
some newer or older version of it and not 0.1 like Espresso?

I had to do a workaround like this

androidTestCompile('com.android.support.test.espresso:espresso-core:2.0') {
exclude group: 'com.android.support.test', module: 'testing-support-lib'
}

to make it compile and run tests.

Example spock tests run nicely. Thanks!


Reply to this email directly or view it on GitHub
#2 (comment)
.

I got it resolved by just taking your two library classes SpockTestingRequestBuilder and AndroidSpockRunner, putting them directly into androidTest folder. There was one incompatibility, where I had to change:

        AndroidRunnerBuilder builder = new AndroidRunnerBuilder(instr, bundle, skipExecution);

into:

        AndroidRunnerParams params = new AndroidRunnerParams(instr, bundle, skipExecution, 10 * 60 * 1000);
        AndroidRunnerBuilder builder = new AndroidRunnerBuilder(params);

I think you cannot base on 0.1, because it's not part of AOSP yet. I found the sources here: testing-support-lib-0.1-sources.jar. On the main page they even mention not being AOSP yet. At least I understand it like that.

The source code hosted under the "Source" tab is still Espresso 1.1 and will be replaced as soon as we launch in AOSP!

Great! Thanks I've been digging through the git logs trying to find 0.1. The code mine is using I'm pretty sure is in ASOP, although that's not really relevant.

If you wouldn't mind submitting a PR that would be awesome. Otherwise I can update this weekend.

They should put it on AOSP sooner or later, but I'm not sure what you want to do in this situation.
Instead of embeeding testing support code into your jar/aar, I would add dependency

compile 'com.android.support.test:testing-support-lib:0.1'

but the problem is it's not on maven central or jcenter. Sadly Google engineers aren't using these and instead force us to download deps via SDK Manager. You can also find source in android-sdk/extras/android/m2repository/com/android/support/test/testing-support-lib/0.1.

I was looking at the diff between your code and what's in AOSP.

Are these two lines in TestRequestBuilder the only change to make it all work?

new ExcludePackageNameFilter("spock"),
new ExcludePackageNameFilter("org.spockframework"),

Neat. How about begging @otw to add them to support-testing-lib? ;)

The reason for this is there is some extra testing package in Spock core that the test runner attempts to run. I'm actually working with Peter to get that removed.

The plan is to have this library evolve into have custom runners that allow you to get the application and activity contexts in your tests similar to the AndroidTestCase and ApplicationTestCase. Once that gets all ironed out I will hopefully get that put into an new module in Spock.

Adding the dependency to the project I think is fine. I really wish Google would put their binaries in JCenter, but since you need all the other android dependencies downloaded I don't think it's too much trouble.

I'm looking at the sources you linked and can't seem to find the 0.1 stuff for the TestRunner, looks like it's just espresso 2.0.

@otw Do you know where I can find the 0.1 source?

I haven't found a repo with these. It's only here: https://code.google.com/p/android-test-kit/source/browse/bin/espresso2.0/testing-support-lib-0.1-sources.jar and in your Android SDK /extras/android/m2repository/com/android/support/test/testing-support-lib/0.1 directory.
Sooner or later it will hit AOSP.

I tried that link, couldn't find it in that zip. That path contains it though! Thanks!

Here is where I was getting the sources for the latest. https://android.googlesource.com/platform/frameworks/testing/