sendoav
03/29/2021, 2:55 PMamadeu01
05/05/2021, 5:14 PMColton Idle
05/14/2021, 2:41 AM@Test
fun `one plus one`() {
val result = 1 + 1
assertThat(result).isEqualTo(2)
}
but when I add
@BeforeClass
fun setup() {
}
Then I get an error rerunning the test. "No tests found for given includes:" Ideas? I've looked on stackoverflow and it seems that having the tests run with intellij vs gradle could be the culprit but my test does actually run successfully without the setup step added and so I'm hard pressed as to why adding that simple block would be making things act strange.
Edit: Figured it out. Needed @BeforeClass @JvmStatic and put that method in a companion object.Chris Jobling
05/21/2021, 3:38 PMNikolay Kasyanov
05/28/2021, 7:57 AMorg.junit...
not importable in tests of multiplatform project? For context, I only have kotlin('test')
and kotlin('test-annotations-common')
in commonTest
and kotlin('test-junit')
in jvmTest
. No direct dependency to JUnit whatsoever, but it’s still importable because it’s still in the classpath I guess?Byron Katz
05/30/2021, 2:34 PMnapperley
08/18/2021, 2:11 AMTobi M.
11/24/2021, 9:12 AMandylamax
12/01/2021, 4:17 AMColton Idle
02/04/2022, 2:30 PMColton Idle
02/07/2022, 9:42 PMBrian Donovan
02/13/2022, 4:23 PM@RunWith(AndroidJUnit4::class)
class LoginTest {
@get:Rule
val composeTestRule = createAndroidComposeRule<MainActivity>()
@Test
fun logInButtonEnabledTest() {
composeTestRule.setContent {
WHApplicationTheme {
LoginScreen({}, {}, {})
}
}
val email = "sampl"
val password = "Sa"
val isValidEmail: Boolean = EmailValidator.isValid(email)
val isValidPassword: Boolean = PasswordValidator.isValid(password)
if (isValidEmail && isValidPassword) {
composeTestRule
.onNodeWithTag(EMAIL_TEXT_FIELD)
.performTextInput(email)
composeTestRule
.onNodeWithTag(PASSWORD_TEXT_FIELD)
.performTextInput(password)
}
composeTestRule
.onNodeWithTag(LOG_IN_BUTTON)
.performClick()
}
}
interface FormValidator {
fun isValid(value: String): Boolean
}
object PasswordValidator : FormValidator {
override fun isValid(value: String): Boolean {
return value.length > 5 && !value.contains(" ")
}
}
object EmailValidator : FormValidator {
override fun isValid(value: String): Boolean {
val emailCheck = "^[A-Za-z](.*)([@])(.+)(\\.)(.+)"
return emailCheck.toRegex().matches(value)
}
}
andylamax
02/20/2022, 1:22 AMBig Chungus
06/22/2022, 8:20 PMoianmol
10/28/2022, 7:05 AMLandry Norris
11/17/2022, 3:07 PMteddy
12/02/2022, 12:29 AMNarayan Iyer
12/14/2022, 1:02 PMBig Chungus
02/20/2023, 10:00 AMBlaž Vantur
04/11/2023, 9:33 AMandylamax
08/08/2023, 12:11 AMgalvas
08/23/2023, 2:53 PMInheritance of sealed classes or interfaces from different module is prohibited
error. I assumed that the tests source would be part of the same module as the production code. Am I missing something? Any tips?Anmol Verma
10/01/2023, 4:00 AMDarryl Pierce
11/27/2023, 7:55 PMJonathan
12/14/2023, 4:44 PMdevice.findObject(By.res(…))
returns null. I can see all queried elements are on screen. I haven’t seen any documentation mentioning that this methods behaves in a best effort fashion. Has anyone experienced this before or know why this happens? I’ve not been able to determine a rhyme or reason for this behavior.
Here, is an excerpt from my StartupBaselineProfile that’s through an exception:
device.findObject(By.res(UiTestingTags.HMOBatterView)).also { batterView ->
device.wait(Until.hasObject(By.res(UiTestingTags.HMOBatterViewBalls)), 10_000)
// Increment the number of balls until the "walk" dialog displays.
batterView.findObject(By.res(UiTestingTags.HMOBatterViewBalls)).also { ballsButton ->
...
}
}
Specifically the NPE happens:
batterView.findObject(By.res(UiTestingTags.HMOBatterViewBalls))I performed a clean and rebuild and the code ran without exception. I’m not sure if this is a factor in the matter but I’m testing on a WearOS emulator (Wear OS Large Round API 33)
Levi
12/20/2023, 6:13 PMsrc/test
to match src/main
?Big Chungus
12/28/2023, 3:01 PMJonathan
01/03/2024, 9:59 PMUiDevice.findObject()
will return null
?Alina Dolgikh [JB]
Alina Dolgikh [JB]