AndroidJUnit4 Should have a public constructor
up vote
0
down vote
favorite
I'm trying to follow Android Developer Docs to write an Instrumented Unit Test, but, of course, it doesn't work. I am getting the error:
Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)
when ever I run my example test:
package com.devetry.ytp
import android.content.Context
import android.support.test.InstrumentationRegistry
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import androidx.test.filters.LargeTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import androidx.test.runner.AndroidJUnitRunner
import org.junit.Assert
import org.junit.Rule
@RunWith(AndroidJUnit4::class)
class ExampleAndroidTest {
/**
* VARIABLES
*/
/**
* LIFE CYCLE
*/
/**
* Example Android Test
*
* An example android test
*/
@Test
fun exampleAndroidTest() {
val context = InstrumentationRegistry.getTargetContext()
Assert.assertEquals("com.devetry.ytp", context.packageName)
}
}
I have tried tried multiple solutions to this specific error I found online, but like most things Android, the solution was either outdated or just simply didn't work. Unfortunately, of all of the solutions, I was unable to even recognize a common theme, thus leaving me stranded.
How can I resolve the error and just get an Instrumented Unit Tests to run?
android android-testing android-instrumentation
add a comment |
up vote
0
down vote
favorite
I'm trying to follow Android Developer Docs to write an Instrumented Unit Test, but, of course, it doesn't work. I am getting the error:
Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)
when ever I run my example test:
package com.devetry.ytp
import android.content.Context
import android.support.test.InstrumentationRegistry
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import androidx.test.filters.LargeTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import androidx.test.runner.AndroidJUnitRunner
import org.junit.Assert
import org.junit.Rule
@RunWith(AndroidJUnit4::class)
class ExampleAndroidTest {
/**
* VARIABLES
*/
/**
* LIFE CYCLE
*/
/**
* Example Android Test
*
* An example android test
*/
@Test
fun exampleAndroidTest() {
val context = InstrumentationRegistry.getTargetContext()
Assert.assertEquals("com.devetry.ytp", context.packageName)
}
}
I have tried tried multiple solutions to this specific error I found online, but like most things Android, the solution was either outdated or just simply didn't work. Unfortunately, of all of the solutions, I was unable to even recognize a common theme, thus leaving me stranded.
How can I resolve the error and just get an Instrumented Unit Tests to run?
android android-testing android-instrumentation
stackoverflow.com/a/44478370/4936904
– Pavneet_Singh
Nov 21 at 17:26
@Pavneet_Singh yup, tried both of those. My Instrumented Test is in the AndroidTest folder and my configuration looks exactly the same...
– Tanner Juby
Nov 21 at 17:34
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to follow Android Developer Docs to write an Instrumented Unit Test, but, of course, it doesn't work. I am getting the error:
Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)
when ever I run my example test:
package com.devetry.ytp
import android.content.Context
import android.support.test.InstrumentationRegistry
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import androidx.test.filters.LargeTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import androidx.test.runner.AndroidJUnitRunner
import org.junit.Assert
import org.junit.Rule
@RunWith(AndroidJUnit4::class)
class ExampleAndroidTest {
/**
* VARIABLES
*/
/**
* LIFE CYCLE
*/
/**
* Example Android Test
*
* An example android test
*/
@Test
fun exampleAndroidTest() {
val context = InstrumentationRegistry.getTargetContext()
Assert.assertEquals("com.devetry.ytp", context.packageName)
}
}
I have tried tried multiple solutions to this specific error I found online, but like most things Android, the solution was either outdated or just simply didn't work. Unfortunately, of all of the solutions, I was unable to even recognize a common theme, thus leaving me stranded.
How can I resolve the error and just get an Instrumented Unit Tests to run?
android android-testing android-instrumentation
I'm trying to follow Android Developer Docs to write an Instrumented Unit Test, but, of course, it doesn't work. I am getting the error:
Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)
when ever I run my example test:
package com.devetry.ytp
import android.content.Context
import android.support.test.InstrumentationRegistry
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import androidx.test.filters.LargeTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import androidx.test.runner.AndroidJUnitRunner
import org.junit.Assert
import org.junit.Rule
@RunWith(AndroidJUnit4::class)
class ExampleAndroidTest {
/**
* VARIABLES
*/
/**
* LIFE CYCLE
*/
/**
* Example Android Test
*
* An example android test
*/
@Test
fun exampleAndroidTest() {
val context = InstrumentationRegistry.getTargetContext()
Assert.assertEquals("com.devetry.ytp", context.packageName)
}
}
I have tried tried multiple solutions to this specific error I found online, but like most things Android, the solution was either outdated or just simply didn't work. Unfortunately, of all of the solutions, I was unable to even recognize a common theme, thus leaving me stranded.
How can I resolve the error and just get an Instrumented Unit Tests to run?
android android-testing android-instrumentation
android android-testing android-instrumentation
asked Nov 21 at 17:21
Tanner Juby
738
738
stackoverflow.com/a/44478370/4936904
– Pavneet_Singh
Nov 21 at 17:26
@Pavneet_Singh yup, tried both of those. My Instrumented Test is in the AndroidTest folder and my configuration looks exactly the same...
– Tanner Juby
Nov 21 at 17:34
add a comment |
stackoverflow.com/a/44478370/4936904
– Pavneet_Singh
Nov 21 at 17:26
@Pavneet_Singh yup, tried both of those. My Instrumented Test is in the AndroidTest folder and my configuration looks exactly the same...
– Tanner Juby
Nov 21 at 17:34
stackoverflow.com/a/44478370/4936904
– Pavneet_Singh
Nov 21 at 17:26
stackoverflow.com/a/44478370/4936904
– Pavneet_Singh
Nov 21 at 17:26
@Pavneet_Singh yup, tried both of those. My Instrumented Test is in the AndroidTest folder and my configuration looks exactly the same...
– Tanner Juby
Nov 21 at 17:34
@Pavneet_Singh yup, tried both of those. My Instrumented Test is in the AndroidTest folder and my configuration looks exactly the same...
– Tanner Juby
Nov 21 at 17:34
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417512%2fandroidjunit4-should-have-a-public-constructor%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
stackoverflow.com/a/44478370/4936904
– Pavneet_Singh
Nov 21 at 17:26
@Pavneet_Singh yup, tried both of those. My Instrumented Test is in the AndroidTest folder and my configuration looks exactly the same...
– Tanner Juby
Nov 21 at 17:34