Skip to content

Commit

Permalink
2.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-tiurin committed Nov 30, 2024
1 parent 474e8ee commit 4892d2d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
12 changes: 5 additions & 7 deletions composeApp/src/commonTest/kotlin/UltronTestFlowTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ import kotlin.test.assertTrue
class UltronTestFlowTest : UltronTest() {
companion object {
var order = 0
var beforeAllTestCounter = -1
var beforeFirstTestCounter = 0
var commonBeforeOrder = -1
var commonAfterOrder = -1
var afterOrder = -1

}

@OptIn(ExperimentalUltronApi::class)
override val beforeFirstTest = {
beforeAllTestCounter = order
beforeFirstTestCounter++
UltronLog.info("Before Class")
}

Expand All @@ -39,6 +38,7 @@ class UltronTestFlowTest : UltronTest() {
var goOrder = -1
order++
before {
assertTrue(beforeFirstTestCounter == 1, message = "beforeFirstTest block should run before all test")
beforeOrder = order
order++
UltronLog.info("Before TestMethod 1")
Expand All @@ -49,8 +49,6 @@ class UltronTestFlowTest : UltronTest() {
}.after {
afterOrder = order
order++
assertTrue(beforeAllTestCounter == 0, message = "beforeAllTests block should run before all test")
assertTrue(beforeAllTestCounter < commonBeforeOrder, message = "beforeAllTests block should run before commonBefore block")
assertTrue(commonBeforeOrder < beforeOrder, message = "beforeOrder block should run after commonBefore block")
assertTrue(beforeOrder < goOrder, message = "Before block should run before 'go'")
assertTrue(goOrder < afterOrder, message = "After block should run after 'go'")
Expand All @@ -64,14 +62,14 @@ class UltronTestFlowTest : UltronTest() {
}.after {
UltronLog.info("After TestMethod 2")
}.go {
assertTrue(beforeAllTestCounter == 0, message = "beforeAllTests block should run only once")
assertTrue(beforeFirstTestCounter == 1, message = "beforeFirstTest block should run only once")
UltronLog.info("Run TestMethod 2")
}
}

@Test
fun simpleTest() = test {
assertTrue(beforeAllTestCounter == 0, message = "beforeAllTests block should run only once")
assertTrue(beforeFirstTestCounter == 1, message = "beforeFirstTest block should run only once")
UltronLog.info("UltronTest simpleTest")
}
}
14 changes: 8 additions & 6 deletions composeApp/src/commonTest/kotlin/UltronTestFlowTest2.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import com.atiurin.ultron.annotations.ExperimentalUltronApi
import com.atiurin.ultron.core.test.UltronTest
import com.atiurin.ultron.log.UltronLog
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class UltronTestFlowTest2 : UltronTest() {
var order = 0
var beforeAllTestCounter = 0
companion object {
var order = 0
var beforeFirstTestCounter = 0
}

@OptIn(ExperimentalUltronApi::class)
override val beforeFirstTest = {
beforeAllTestCounter = order
beforeFirstTestCounter++
order++
UltronLog.info("Before Class")
}
Expand All @@ -22,6 +25,7 @@ class UltronTestFlowTest2 : UltronTest() {
var goOrder = -1
order++
before {
assertEquals(1, beforeFirstTestCounter, message = "beforeFirstTest block should run before all test")
beforeOrder = order
order++
UltronLog.info("Before TestMethod 1")
Expand All @@ -31,8 +35,6 @@ class UltronTestFlowTest2 : UltronTest() {
UltronLog.info("Run TestMethod 1")
}.after {
afterOrder = order
assertTrue(beforeAllTestCounter == 0, message = "beforeAllTests block should run before all test")
assertTrue(beforeOrder > beforeAllTestCounter, message = "Before block should run after 'Before All'")
assertTrue(beforeOrder < goOrder, message = "Before block should run before 'go'")
assertTrue(goOrder < afterOrder, message = "After block should run after 'go'")
}
Expand All @@ -45,7 +47,7 @@ class UltronTestFlowTest2 : UltronTest() {
}.after {
UltronLog.info("After TestMethod 2")
}.go {
assertTrue(beforeAllTestCounter == 0, message = "beforeAllTests block should run only once")
assertEquals(1, beforeFirstTestCounter, message = "beforeFirstTest block should run before all test")
UltronLog.info("Run TestMethod 2")
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ kotlin.mpp.enableCInteropCommonization=true

GROUP=com.atiurin
POM_ARTIFACT_ID=ultron
VERSION_NAME=2.5.0-alpha16
VERSION_NAME=2.5.1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.junit.Test
class UltronTestFlowTest : BaseTest() {
companion object {
var order = 0
var beforeAllTestCounter = -1
var isBeforeFirstTestCounter = 0
var commonBeforeOrder = -1
var commonAfterOrder = -1
var afterOrder = -1
Expand All @@ -17,7 +17,7 @@ class UltronTestFlowTest : BaseTest() {

@OptIn(ExperimentalUltronApi::class)
override val beforeFirstTest = {
beforeAllTestCounter = order
isBeforeFirstTestCounter++
UltronLog.info("Before Class")
}

Expand All @@ -39,6 +39,7 @@ class UltronTestFlowTest : BaseTest() {
var goOrder = -1
order++
before {
assert(isBeforeFirstTestCounter == 1, lazyMessage = { "beforeFirstTest block should run before commonBefore block" })
beforeOrder = order
order++
UltronLog.info("Before TestMethod 1")
Expand All @@ -49,8 +50,6 @@ class UltronTestFlowTest : BaseTest() {
}.after {
afterOrder = order
order++
assert(beforeAllTestCounter == 0, lazyMessage = { "beforeAllTests block should run before all test" })
assert(beforeAllTestCounter < commonBeforeOrder, lazyMessage = { "beforeAllTests block should run before commonBefore block" })
assert(commonBeforeOrder < beforeOrder, lazyMessage = { "beforeOrder block should run after commonBefore block" })
assert(beforeOrder < goOrder, lazyMessage = { "Before block should run before 'go'" })
assert(goOrder < afterOrder, lazyMessage = { "After block should run after 'go'" })
Expand All @@ -64,14 +63,14 @@ class UltronTestFlowTest : BaseTest() {
}.after {
UltronLog.info("After TestMethod 2")
}.go {
assert(beforeAllTestCounter == 0, lazyMessage = { "beforeAllTests block should run only once" })
assert(isBeforeFirstTestCounter == 1, lazyMessage = { "beforeFirstTest block should run only once" })
UltronLog.info("Run TestMethod 2")
}
}

@Test
fun simpleTest() = test {
assert(beforeAllTestCounter == 0, lazyMessage = { "beforeAllTests block should run only once" })
assert(isBeforeFirstTestCounter == 1, lazyMessage = { "beforeAllTests block should run only once" })
UltronLog.info("UltronTest simpleTest")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ open class UltronTest(
*
* @throws UltronException if the test class is anonymous.
*/
private val className = this::class.qualifiedName
private val className = this::class.simpleName
?: throw UltronException("Don't use anonymous class for UltronTest")

/**
Expand Down

0 comments on commit 4892d2d

Please sign in to comment.