-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
Create compose base #439
Create compose base #439
Conversation
e63273d
to
eda9763
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, looks good to me 👌🏼
Just added some comments that could be an improvement
import androidx.compose.ui.test.junit4.AndroidComposeTestRule | ||
import androidx.compose.ui.test.junit4.ComposeTestRule | ||
|
||
internal fun ComposeTestRule.resources() = if (this is AndroidComposeTestRule<*, *>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it!
WrappedTextComposable(text = text, nodeTestTag = "Node test") | ||
} | ||
|
||
composeTestRule.onNodeWithTag("Node test").assertIsDisplayed(text = "Barista") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use text
variable instead of hardcoded Barista
text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same than before :·)
barista-compose/src/main/java/com/alorma/barista_compose/assertion/BaristaAssertions.kt
Outdated
Show resolved
Hide resolved
Hello! 👋 Same than @victormpineda : I would try to mimic Barista's API. Why don't call those methods Thanks for the contribution, of course! It's a big step forward 💌 |
+1 on the Barista-style API. My idea of a Barista for Compose would be to have the same simple straightforward human-readable API. Function names with a few words with a couple of parameters to perform the most common tasks. A more flexible or modularized API is cool too (I don't know if it's needed, I haven't tried Compose test API yet). But, in my opinion, it would be a different thing from Barista. |
If I'm not wrong there are different methods for hardcoded text and string resource. The named parameters are optional and related to the specific Compose API. |
Hi @costular ! Right now, the API is like this: assertDisplayed("Hello world");
assertDisplayed(R.string.hello_world);
assertDisplayed(R.id.button);
assertDisplayed(R.id.button, "Hello world")
assertDisplayed(R.id.button, R.string.hello_world) |
Maybe you understood me wrong or I did. You said that you prefer to receive plain parameters and what I'm saying is this PR contains different methods for hardcoded and resource assertions (like you asked) plus Compose API arguments: useUnmergedTree: Boolean = false,
substring: Boolean = false,
ignoreCase: Boolean = false I think if we change the order of the arguments like this: fun ComposeTestRule.assertDisplayed(
@StringRes textRes: Int,
useUnmergedTree: Boolean = false,
substring: Boolean = false,
ignoreCase: Boolean = false
) We can do something like this: // Plain
composeTestRule.assertDisplayed(R.string.some_text)
// Use unmerged tree which is part of Compose API
composeTestRule.assertDisplayed(R.string.some_text, useUnmergedTree = true) What do you think? |
Ah! Seems great! But we need an
|
This would work perfectly! |
What do you think, @alorma? Does it break your plans too much? |
Hi everyone! Wow so great discussions here! I won't be able to work on this until later today but yeah, your proposals look great. Let me redo this PR applying your suggestions |
Hello @rocboronat @Sloy @costular @victormpineda!(wow, so many contributors on this PR!!!) I've applied all the comments suggested on the PR, so now the API matches barista style methods. What do you think? Is ok as a first step to have a |
@alorma Go ahead! IMHO it suits our needs for the first step with |
@rocboronat @Sloy Any updates on this? |
TextComposable(text = "Hello world") | ||
} | ||
|
||
composeTestRule.assertDisplayed(text = "Hello world") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the same approach we did in the regular Barista, like composeTestRule.assertDisplayed("Hello world")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, removed it!
Hello @alorma! That's my only feedback. As soon as you update the tests or just add cases that call the assertDisplayed method by the regular way, without specifying the Congratulations on this PR! It's a step that will make lots of people happier 😄 |
4816737
to
cda36e2
Compare
cda36e2
to
c117b81
Compare
Create barista-compose module and create first assertions.
Both depending on
ComposeTestRule
and `SemantincNodeInteraction``So test will look: