- androidTestMock : No tests were found error, «Empty Test Suite» #27
- Comments
- jimandreas commented May 9, 2016
- slinzner commented May 11, 2016
- jimandreas commented May 12, 2016 •
- jimandreas commented May 12, 2016
- slinzner commented May 12, 2016
- slinzner commented May 13, 2016
- jimandreas commented May 13, 2016
- jimandreas commented May 18, 2016 •
- Нет тестов, найденных для данного, включает ошибку при запуске параметризованного модульного теста в Android Studio
- «No tests were found» when running test class in IntelliJ #2815
- Comments
- alixwar commented Jan 5, 2017 •
- Description
- Steps to Reproduce
- Robolectric & Android Version
- xian commented Jan 6, 2017 •
- klinker41 commented Jan 7, 2017 •
- alixwar commented Jan 9, 2017 •
- Android Studio «No tests were found»
- 19 Answers
- No tests were found: Class not found: «com.example.myapplication
- Breadcrumb
- pupsozeyde
androidTestMock : No tests were found error, «Empty Test Suite» #27
Comments
jimandreas commented May 9, 2016
I am hitting this error at the following codelab step:
The Android studio setup is shown in the snips below on Windows 7. I have not found a solution for this problem. It appears that the use of the «AndroidTestMock» facility is not in wide use — and so there is little to be found out there for guidance. Hmm.
The text was updated successfully, but these errors were encountered:
slinzner commented May 11, 2016
Unfortunately I cannot reproduce this issue. Do you mind sending me the logcat for the test run?
jimandreas commented May 12, 2016 •
There wasn’t anything in the logcat when I asked studio to run ONLY the NoteDetailScreenTest.
Same error: «No tests were found»
OK I will ask it to run everything in the AndroidTestMock category. Well that was interesting. It did more stuff but ALSO ran tests in «androidTest»:
with this result:
and this logcat:
**** and with this test output:
jimandreas commented May 12, 2016
Oh yes in case there are questions — here is my NoteDetailScreenTest.java renamed as a .txt file for Githup importing:
slinzner commented May 12, 2016
I cannot reproduce the «no tests found» error on my machine, can you give me more details, ie. Android Studio version and device/api level combination you’re running this on? Can you also confirm that you are using the correct run configuration for instrumentation and not the unit test configuration?
Running tests in the «androidMockTest» variant source set will also run tests in the androidTest source set. That’s the expected behavior since a flavors are just overlays over a base source set, like «main» or «androidTest».
For the failing tests, when running tests in «androidMockTest», what I can see from the log is that the tests fail because you haven’t implemented step-8/step-9 yet. If you look closely you will spot an assertion error: «java.lang.AssertionError: Implement in step 8/Implement in step 9». So following the instructions and implement all the steps should fix those failing tests. In this case it also seems like NoteDetailScreenTest is picked up and run, which leads me to believe that the «no found error» could be using the wrong run configuration.
Please also make sure you have animations turned off, on your device and emulator, to avoid random flakiness of tests.
slinzner commented May 13, 2016
I was able to reproduce the issue on my other machine and it confirmed my suspicion. The error you’re seeing happens if AS for some reason thinks that the test that you’re about to run is a unit and not an instrumentation test. Often this error goes away buy just clicking on the package instead of the actual class. I added instructions to the trouble shooting section of the codelab with a screenshot to make it clear how to recover from this issue.
jimandreas commented May 13, 2016
Thank you, confirmed. If I click on the package and not the test, then AS does find the test and executes it. This unblocks my progress. I can now proceed further with the codelab! Cheers, Jim A
jimandreas commented May 18, 2016 •
UPDATE: at the step-9 branch now, repeating the same workaround that functioned at step-7, has STOPPED WORKING. Now the workaround for running the NoteDetailScreenTest, which was to run the test at the package level, on my windows 7 system with Latest and Greatest Studio versions:
fails at the unit test
fails at the notedetail package
fails at the com.example.android.testing.notes package level
Note that the workaround continues to work in the step-7 version — still present on my system as a different Studio project.
I updated the library versions of the step-7 branch project to the step-9 versions. This did not have any effect. The workaround of running the test in the step-7 branch functions, but the workaround fails in the step-9 branch project.
screenshot of failure in the step-9 branch project:
Источник
Нет тестов, найденных для данного, включает ошибку при запуске параметризованного модульного теста в Android Studio
Я попытался запустить параметризованный модульный тест, как показано ниже, в Android Studio.
В результате появляется сообщение об отсутствии тестового запуска. Однако, если я удалил параметризованные и изменил их на индивидуальный тест. Оно работает. Кто-нибудь может пролить свет, почему это не работает? Параметризованный модульный тест еще не поддерживается в разработке для Android? Благодарность!
Ниже приведена ошибка с трассировкой стека.
Добавьте в свой build.gradle:
Убедитесь, что вы импортируете @Test аннотацию из правильной библиотеки:
Я использую JUnit 4, и у меня сработало изменение настроек IntelliJ для «Gradle -> Выполнить тесты с использованием» с «Gradle (по умолчанию)» на «IntelliJ IDEA».
Чтобы добавить к уже отличному и простому решению, предоставляемому Przemek315 , ту же конфигурацию, если вы используете Kotlin DSL:
Нашел способ запустить тест в Android Studio. По-видимому, запуск его с использованием конфигурации Gradle не будет выполнять никаких тестов. Вместо этого я использую конфигурацию JUnit. Самый простой способ сделать это — выбрать «Выбрать тестовый класс для запуска» и щелкнуть правой кнопкой мыши. Затем выберите «Выполнить». После этого вы увидите 2 варианта запуска. Выберите нижний (JUnit) согласно изображению
(примечание: если вы не можете найти 2 конфигурации запуска для выбора, вам необходимо сначала удалить ранее использованную конфигурацию (конфигурация Gradle). Это можно сделать, щелкнув значок «Выбрать конфигурацию запуска / отладки» в верхней части Панель инструментов.
Если вы используете intellij и хотите использовать gradle, вам нужно добавить это в раздел зависимостей файла build.gradle:
Для меня причина сообщения об ошибке
Не найдено тестов для данного включает
непреднамеренно добавил .java тестовый файл в мой src/test/kotlin тестовый каталог. После перемещения файла в правильный каталог, src/test/java тест снова выполняется, как ожидалось.
Kotlin DSL : добавьте в свой build.gradle.kts
Gradle DSL : добавьте в свой build.gradle
Вы можете проверить, является ли ваш метод частным. Потратил много времени на исправление этой глупой ошибки .
Источник
«No tests were found» when running test class in IntelliJ #2815
Comments
alixwar commented Jan 5, 2017 •
Description
When running tests for a class in IntelliJ I get the error:
Process finished with exit code -2
Empty test suite.
This used to work in Robolectric 3.1.4.
I have the following project structure (Multi-module):
Steps to Reproduce
Robolectric & Android Version
Other relevant versions:
Android
- compileSdkVersion 25
- buildToolsVersion «25.0.2»
- minSdkVersion 19
- targetSdkVersion 22
The text was updated successfully, but these errors were encountered:
xian commented Jan 6, 2017 •
Do you see any other error messages? The @Config(emulateSdk = . ) is suspicious: emulateSdk was renamed to sdk around Robolectric 3.0.
klinker41 commented Jan 7, 2017 •
I’m seeing a similar error to this with version 3.2, except I think for different reasons.
Currently, I’ve configured my tests to run with multiple SDK versions:
When I try and run an individual test, I get the following error logged:
It looks like when you add multiple SDKs to test against, Robolectric will rename the tests to also include the SDK version run with, for example test_putIntoIntent[16] . My guess is that this is where IntelliJ is failing, it doesn’t know about that renaming so it’s simply trying to run test_putIntoIntent .
On a somewhat related note, even when I have tests running against multiple SDK versions, each is named the same thing. This means that I have 2 tests that get logged in the results when I run all tests, but they are named the same thing ( test_putIntoIntent[16] and test_putIntoIntent[16] instead of test_putIntoIntent[16] and test_putIntoIntent[25] ). I did however confirm that it was using different SDK versions for each by using System.out.println(Build.VERSION.SDK_INT) and saw 16 and 25 logged in their respective tests. This is definitely a separate problem, so I’m happy to open another issue for it if you’d prefer @xian.
alixwar commented Jan 9, 2017 •
Do you see any other error messages? The @config(emulateSdk = . ) is suspicious: emulateSdk was renamed to sdk around Robolectric 3.0.
I will update my example (same behavior in both cases). No more information in the logs unfortunately.
This is the JVM command:
Источник
Android Studio «No tests were found»
Has anyone been able to get tests to run in Android Studio (from the GUI and not terminal), I have been unable to run tests from the GUI.
Everytime I try to run tests through the GUI I just get the following message:
I am able to run the tests from terminal using the following command:
I am running Android Studio 0.5.2 with Gradle 1.11 with Plugin 0.9.0 on Mac OSX
My project structure is as follows;
My build.gradle file looks similar to the following:
If anyone has any suggestions, I will be more than happy to here them.
19 Answers
Today I had the same problem with some Espresso tests and it was getting me crazy because everything seemed normal. Finally I discovered the problem was because the method annotated with @BeforeClass was throwing an exception. If something goes wrong in that method, the stacktrace of the exception is not shown in the Log window of the Run tab but in the Log window of the Android Monitor tab
If you want to reproduce the problem just add this to your testing class:
This can happen when the type of your run configuration is incorrect.
With me, this goes wrong when running an Espresso test which used to be a unit test. For some reason it still uses the Android JUnit test configuration when running this test. Manually creating an Android Instrumented Test solves the problem.
Just for posterity sakes, here’s the solution that worked for me —
The error you’re seeing happens if AS for some reason thinks that the test that you’re about to run is a unit and not an instrumentation test. Often this error goes away buy just clicking on the package instead of the actual class.
I just ran the tests by right clicking on the package name and choosing «Run ‘Tests in
Ok, I found the cause of my problem.
In the misc.xml file which is located in the .idea folder of my project had an invalid attribute value for the ProjectRootManager component, which looked like the following:
So changing the project-jdk-name attribute value to just «1.6», fixed the problem for me. Below is what it looked like after I had updated the value.
Hope this helps anyone out.
To run instrumentation test cases on android mobile device with kotlin, add below things into your app build.gradle:
Add these permissions:
I used below gradle version:
Then in the src->androidTest->java->com.example.demo-> create class DemoTest.kt. If you need context, then get it via InstrumentationRegistry.getInstrumentation().targetContext
If your test cases requires any permissions, then add below rule:
You can do all set up inside:
and then write test cases like this:
None of the above worked for me (invalidate caches. ).
What worked was:
- click the configurations list drop down in the main toolbar.
- In it click «Edit configuration. «.
- Delete the entry for my test.
- Back to the source, click the |>| button of the test I wanted to run.
It then inexplicably worked.
For me it was stupid thing. Simply switching from Release build variant to Debug solved the problem.
As mentioned here by azizbekian in the Android 10 API 29 documentation this issue can happen when running tests on an Emulator for the first time where the app targets API29.
The emulator may be waiting for user input on a screen showing:
Choose what to allow TestServices to access
There is more information about this in the docs here, but it seems there is a known issue with some versions of the android-test dependencies that can cause this prompt to appear.
So be sure to check the screen on your emulator. In my case the issue was that my Emulator was awaiting confirmation that the TestServices component was granted the Storage permission, as per the screenshot in the linked SO issue and the Android documentation.
Источник
No tests were found: Class not found: «com.example.myapplication
Breadcrumb
pupsozeyde
New member
I wanted to run an instrumented test as this tutorial:
I wanted to run a uiautomator test but before that first I tried to run a deafult already existing test file, `MyApplication2\app\src\androidTest\java\com\example\myapplication\ExampleInstrumentedTest.kt`
The file is like this: developer.android.com/studio/test
«`kt
package com.example.myapplication
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented test, which will execute on an Android device.
*
*/
@runwith(AndroidJUnit4::class)
class ExampleInstrumentedTest <
@test
fun useAppContext() <
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals(«com.example.myapplication», appContext.packageName)
>
>
«`
Then, I tried to run the test file with: right clicking on the flie > Run «ExampleInstrumentedTest»
But I got an error:
«`
Process finished with exit code 1
Class not found: «com.example.myapplication.ExampleInstrumentedTest»
«`
and not sure you need this info but just in case here is `build.gradle`:
«`
apply plugin: ‘com.android.application’
apply plugin: ‘kotlin-android’
apply plugin: ‘kotlin-android-extensions’
android <
compileSdkVersion 30
buildToolsVersion «30.0.2»
Источник