Skip to content
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

Make it an error when there is no "isShould" and "describe" block #4

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ class BehaviorsTreeBuilder<T>(private val parentDescription: String = "") {
children.add(TestNode.ItShould(description) { describedBehavior -> action(describedBehavior) })
}

fun build(name: String): TestNode.Describe<T> = TestNode.Describe(name, children)
fun build(name: String): TestNode.Describe<T> {
if (children.all { it is TestNode.DoIt }) {
throw IllegalStateException("No itShould or describe block found for $name. Please add itShould or describe block, otherwise, it will not be executed.")
}
return TestNode.Describe(name, children)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import kotlinx.coroutines.runBlocking
import org.junit.Test

class DSLBehaviorTest {
@Test
fun `when just using describe behavior with doIt it should not run`() {
@Test(expected = IllegalStateException::class)
fun `when just using describe behavior with doIt it should be error`() {
runBlocking {
describeBehaviors<Unit>("root") {
doIt {
error("should not be called")
}
}.forEach { it.execute(Unit) }
}
Expand Down
Loading