Git Product home page Git Product logo

Comments (10)

IgorGanapolsky avatar IgorGanapolsky commented on June 5, 2024

What is the error you see in Android Studio?

from testing-samples.

fmt-Println-MKO avatar fmt-Println-MKO commented on June 5, 2024

I just used gradle in terminal, the build seems to be success, but if you check the unit test results: there is nothing, just adding a error to some unit tests files, build still success because files where never compiled.

I tried now with AndroidStudio,
and got this error:

Test filtering is not supported for given version of JUnit. Please upgrade JUnit version to at least 4.6.

from testing-samples.

JoseAlcerreca avatar JoseAlcerreca commented on June 5, 2024

What task are you using to run the tests? This are device/emulator tests, not local-JVM tests. You can find instructions in the README.md file.

from testing-samples.

IgorGanapolsky avatar IgorGanapolsky commented on June 5, 2024

I am using Android Studio. I right-click on the test file and run it.

from testing-samples.

fmt-Println-MKO avatar fmt-Println-MKO commented on June 5, 2024

ok, so for unittesting/BasicUnitAndroidTest
I run on console:
gradle clean test-> build success but unit tests not executed, (could be seen by either making a compile error into the class: LogHistoryAndroidUnitTest or when opening the unit test reports
with ./gradlew clean test the same
gradle --version (installed with brew)

------------------------------------------------------------
Gradle 2.3
------------------------------------------------------------

Build time:   2015-02-16 05:09:33 UTC
Build number: none
Revision:     586be72bf6e3df1ee7676d1f2a3afd9157341274

Groovy:       2.3.9
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_31 (Oracle Corporation 25.31-b07)
OS:           Mac OS X 10.10.2 x86_64

./gradlew --verion

------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------

Build time:   2014-11-24 09:45:35 UTC
Build number: none
Revision:     6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a

Groovy:       2.3.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_31 (Oracle Corporation 25.31-b07)
OS:           Mac OS X 10.10.2 x86_64

now I go to Android Studio,
import new Project, use gradle wrapper.
right click on the LogHistoryAndroidUnitTest and execute Unit test:
I first get this error: Gradle error - Execution failed for task ':app:dexDebug'
now I change settings in AndroidStudio to use my local gradle version,
try to run the test again, this time with this error: **!!! JUnit version 3.8 or later expected:

java.lang.RuntimeException: Stub!**

when I try to execute gradle test from Android Studio I get this error: Execution failed for task ':app:testDebug'.
Test filtering is not supported for given version of JUnit. Please upgrade JUnit version to at least 4.6.

so I never get the unit test running, don't know what I do wrong :/

back to Console
when I rename app/src/androidTest/ to app/src/test/
and run gradle testagain i get a lot of compile errors:
unittesting/basicunitandroidtest/LogHistoryAndroidUnitTest.java:20: error: package android.support.test.runner does not exist import android.support.test.runner.AndroidJUnit4;

this this time the class is found but not the dependencies...

if I change in app.gradle the dependencies from androidTestCompile to testCompile
and run gradle test again
i will end up with this error

java.lang.Exception: Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)

if you have any idea what i do wrong please tell me, because i have the same behavior with my own project...
Also i don't get why AndroidStudio seems to work different, i kind of executing the Unit Test directly , or with gradle, and it also differs from the console.
I would expect that using gradle from console or AndroidStudio should be no difference ?

from testing-samples.

JoseAlcerreca avatar JoseAlcerreca commented on June 5, 2024

These tests are not run locally but in device/emulator, so they live in androidTest and should be executed using the connectedCheck task or from Android Studio using the instructions found in the README in the root of the project.

from testing-samples.

fmt-Println-MKO avatar fmt-Println-MKO commented on June 5, 2024

ahhhhh, ok got it, now all this test and androitTest makes sense ....
its working now as it should, also unit tests in my project are working :)

sorrryyy guys for noise :(

from testing-samples.

stefanlam88 avatar stefanlam88 commented on June 5, 2024

Hi fmt,

Do you manage to get it running?
How you fix the error?

java.lang.Exception: Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)

Thanks a lot

from testing-samples.

fmt-Println-MKO avatar fmt-Println-MKO commented on June 5, 2024

the error was on my side.
for android test you need an emulator than its running as is it should

from testing-samples.

stefanlam88 avatar stefanlam88 commented on June 5, 2024

Hi I intend to use AndroidJUnit4. If I take out RunWith Android JUnit4 then no issue.. I mean the local unit test without device

from testing-samples.

Related Issues (20)

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.