-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
ActivityScenario is null when executing the test #126
Comments
You are missing @WithJunitRule annotation. Also better place rules in separate file. Check readme and cuculator sample |
I checked cukeulator before but it's hard to understand which steps are needed and which are showcase of different approach. // ComposeRuleHolder.kt
@WithJunitRule
@Singleton
class ComposeRuleHolder @Inject constructor() {
@get:Rule(order = 1)
val composeTestRule = createAndroidComposeRule<HiltAppCompatActivity>()
} And updated the steps accordingly: @HiltAndroidTest
class Steps(
val composeRuleHolder: ComposeRuleHolder
) : SemanticsNodeInteractionsProvider by composeRuleHolder.composeTestRule {
private val composeTestRule
get() = composeRuleHolder.composeTestRule
@Given("I open the App")
fun I_open_the_App() {
composeTestRule.setContent {
Box(Modifier.testTag("Tv").fillMaxSize()) {
Box(
modifier = Modifier
.size(100.dp)
.align(Alignment.Center)
.background(Color.Blue)
)
}
}
}
@Then("The TV tab is displayed")
fun Then_the_TV_tab_is_displayed() {
onNodeWithTag("Tv").assertIsDisplayed()
}
} I keep getting the same exception. I tried adding |
I need to check if |
I tried There are two reasons for using a specific activity
I was checking the pull request and it looks like the cukeulator uses the latest changes that I think are not part of version 7.14.0 could that be a problem? |
Could be, I've tested locally with latest version and |
But imho the only difference is that @singleton and @Inject annotation in ComposeRuleHolder is actually ignored in version 7.14.0 |
@lsuski I found the problem. I had my steps in |
it is a mistake, |
I get a null pointer exception when executing the tests. If I write the same test without
Cucumber
and use plainAndroidJUnitRunner
the test as supposed to👓 What did you see?
✅ What did you expect to see?
Test runs
📦 Which tool/library version are you using?
io.cucumber:cucumber-android
io.cucumber:cucumber-android-hilt
🔬 How could we reproduce it?
Feature file
Steps to reproduce the behavior:
NullPointerException
📚 Any additional context?
Plain Compose test to compare.
The text was updated successfully, but these errors were encountered: