Skip to content

Commit

Permalink
Merge pull request #98 from DroidKaigi/takahirom/use-it-instead-of-ch…
Browse files Browse the repository at this point in the history
…eck/2024-07-07

Use it instead of 'check' to follow the naming convention
  • Loading branch information
takahirom authored Jul 7, 2024
2 parents 4c49acc + 6c7ccde commit ca180ba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ suspend fun <T> DescribedTestCase<T>.execute(robot: T) {
println("Executing step: $index ($description)")
when (step) {
is TestNode.Run -> step.action(robot)
is TestNode.Check -> {
is TestNode.It -> {
if (step.description == targetCheckDescription) {
step.action(robot)
}
Expand All @@ -27,7 +27,7 @@ suspend fun <T> DescribedTestCase<T>.execute(robot: T) {
sealed class TestNode<T> {
data class Describe<T>(val description: String, val children: List<TestNode<T>>) : TestNode<T>()
data class Run<T>(val action: suspend T.() -> Unit) : TestNode<T>()
data class Check<T>(val description: String, val action: suspend T.() -> Unit) : TestNode<T>()
data class It<T>(val description: String, val action: suspend T.() -> Unit) : TestNode<T>()
}

data class DescribedTestCase<T>(
Expand All @@ -46,7 +46,7 @@ data class AncestryNode<T>(
data class CheckNode<T>(
val description: String,
val fullDescription: String,
val node: TestNode.Check<T>,
val node: TestNode.It<T>,
val ancestry: List<AncestryNode<T>>,
)

Expand All @@ -63,8 +63,8 @@ class TestCaseTreeBuilder<T> {
children.add(TestNode.Run { action() })
}

fun check(description: String, action: suspend T.() -> Unit) {
children.add(TestNode.Check(description) { action() })
fun it(description: String, action: suspend T.() -> Unit) {
children.add(TestNode.It(description) { action() })
}

fun build(): TestNode.Describe<T> = TestNode.Describe("", children)
Expand Down Expand Up @@ -93,9 +93,9 @@ private fun <T> collectCheckNodes(root: TestNode.Describe<T>): List<CheckNode<T>
}
}

is TestNode.Check -> {
is TestNode.It -> {
val fullDescription = if (parentDescription.isNotBlank()) {
"$parentDescription - ${node.description}"
"$parentDescription - it ${node.description}"
} else {
node.description
}
Expand Down Expand Up @@ -136,7 +136,7 @@ private fun <T> createTestCase(checkNode: CheckNode<T>): DescribedTestCase<T> {
steps.add(node)
}

is TestNode.Check -> {
is TestNode.It -> {
if (node == checkNode.node) {
steps.add(node)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ class TimetableItemDetailScreenTest(private val testCase: DescribedTestCase<Time
run {
setupScreenContent()
}
check("should show session detail title") {
it("should show session detail title") {
// FIXME: Add check for session detail title
captureScreenWithChecks()
}
check("check accessibility") {
it("check accessibility") {
checkAccessibilityCapture()
}
describe("click bookmark button") {
run {
clickBookmarkButton()
}
check("should show bookmarked session") {
it("should show bookmarked session") {
// FIXME: Add check for bookmarked session
captureScreenWithChecks()
}
describe("click bookmark button again") {
run {
clickBookmarkButton()
}
check("should show unbookmarked session") {
it("should show unbookmarked session") {
// FIXME: Add check for unbookmarked session
captureScreenWithChecks()
}
Expand All @@ -83,7 +83,7 @@ class TimetableItemDetailScreenTest(private val testCase: DescribedTestCase<Time
run {
scroll()
}
check("should show scrolled session detail") {
it("should show scrolled session detail") {
// FIXME: Add check for scrolled session detail
captureScreenWithChecks()
}
Expand All @@ -94,7 +94,7 @@ class TimetableItemDetailScreenTest(private val testCase: DescribedTestCase<Time
setFontScale(0.5f)
setupScreenContent()
}
check("should show session detail with small font scale") {
it("should show session detail with small font scale") {
captureScreenWithChecks()
}
}
Expand All @@ -103,7 +103,7 @@ class TimetableItemDetailScreenTest(private val testCase: DescribedTestCase<Time
setFontScale(1.5f)
setupScreenContent()
}
check("should show session detail with large font scale") {
it("should show session detail with large font scale") {
captureScreenWithChecks()
}
}
Expand All @@ -112,7 +112,7 @@ class TimetableItemDetailScreenTest(private val testCase: DescribedTestCase<Time
setFontScale(2.0f)
setupScreenContent()
}
check("should show session detail with huge font scale") {
it("should show session detail with huge font scale") {
captureScreenWithChecks()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TimetableScreenTest(private val testCase: DescribedTestCase<TimetableScree
setupTimetableServer(ServerStatus.Operational)
setupTimetableScreenContent()
}
check("should show timetable items") {
it("should show timetable items") {
captureScreenWithChecks(checks = {
checkTimetableItemsDisplayed()
})
Expand All @@ -51,7 +51,7 @@ class TimetableScreenTest(private val testCase: DescribedTestCase<TimetableScree
run {
clickFirstSessionBookmark()
}
check("should show bookmarked session") {
it("should show bookmarked session") {
// FIXME: Add check for bookmarked session
captureScreenWithChecks()
}
Expand All @@ -60,15 +60,15 @@ class TimetableScreenTest(private val testCase: DescribedTestCase<TimetableScree
run {
clickFirstSession()
}
check("should show session detail") {
it("should show session detail") {
checkClickedItemsExists()
}
}
describe("click timetable ui type change button") {
run {
clickTimetableUiTypeChangeButton()
}
check("should change timetable ui type") {
it("should change timetable ui type") {
// FIXME: Add check for timetable ui type change
captureScreenWithChecks()
}
Expand All @@ -79,7 +79,7 @@ class TimetableScreenTest(private val testCase: DescribedTestCase<TimetableScree
setupTimetableServer(ServerStatus.Error)
setupTimetableScreenContent()
}
check("should show error message") {
it("should show error message") {
// FIXME: Add check for error message
captureScreenWithChecks()
}
Expand Down

0 comments on commit ca180ba

Please sign in to comment.