Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compileing main source when compile unit test sources #7

Closed
nenick opened this issue Mar 4, 2015 · 5 comments
Closed

Not compileing main source when compile unit test sources #7

nenick opened this issue Mar 4, 2015 · 5 comments

Comments

@nenick
Copy link
Owner

nenick commented Mar 4, 2015

When you try to run unit tests from a library module then you must compile the main sources first. gradle lib:assembleDebug

Issue is tracked at https://code.google.com/p/android/issues/detail?id=158251

@vanniktech
Copy link

Awesome. Works perfectly fine for me. If you want to just use ./gradlew clean test you have to add this to build.gradle:

tasks.withType(Test) {
    dependsOn assembleDebug
}

Although than you may get a problem with the testRelease task. Therefore execute:

./gradlew clean test -x testRelease

@nenick
Copy link
Owner Author

nenick commented Mar 14, 2015

here is an enhanced version

afterEvaluate { project ->
    android.libraryVariants.each { variant ->
        tasks.getByName("test${ variant.name.capitalize()}") {
            dependsOn "assemble${ variant.name.capitalize()}"
        }
    }
}

@jaredsburrows
Copy link
Contributor

Isnt this issue a duplicate of #5?

@nenick
Copy link
Owner Author

nenick commented Apr 12, 2015

They are two different issues.

This one miss the compiled main classes of the current library module under test. Google issue was merged into https://code.google.com/p/android/issues/detail?id=156027

The other one miss resource files specified under test (and is already fixed with 1.2beta).

@nenick
Copy link
Owner Author

nenick commented May 3, 2015

Fixed with gradle android plugin 1.2.+

@nenick nenick closed this as completed May 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants