Skip to content

Commit bb6022c

Browse files
committed
Test for @nested classes
1 parent 92bf9df commit bb6022c

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/main/kotlin/io/github/tobi/laa/spring/boot/embedded/redis/FindTestClassAnnotation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ internal inline fun <reified T : Annotation> findTestClassAnnotation(
1010
var clazz = testClass
1111
var annotation = findAnnotation(clazz, annotationType)
1212
while (annotation == null && searchEnclosingClass(clazz) && clazz.enclosingClass != null) {
13-
annotation = findAnnotation(clazz, annotationType)
1413
clazz = clazz.enclosingClass
14+
annotation = findAnnotation(clazz, annotationType)
1515
}
1616
return annotation
1717
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.github.tobi.laa.spring.boot.embedded.redis.server
2+
3+
import io.github.tobi.laa.spring.boot.embedded.redis.IntegrationTest
4+
import io.github.tobi.laa.spring.boot.embedded.redis.RedisTests
5+
import org.junit.jupiter.api.DisplayName
6+
import org.junit.jupiter.api.Nested
7+
import org.junit.jupiter.api.Test
8+
import org.springframework.beans.factory.annotation.Autowired
9+
10+
@EmbeddedRedisServer
11+
@DisplayName("Using @EmbeddedRedisServer on a top level class with nested classes should work fine")
12+
class NestedClassesTest {
13+
14+
@Nested
15+
@IntegrationTest
16+
@DisplayName("Nested class should work with embedded Redis server from top level class")
17+
inner class InnerClass {
18+
19+
@Autowired
20+
private lateinit var given: RedisTests
21+
22+
@Test
23+
@DisplayName("It should be possible to write to Redis and the data should be available afterwards")
24+
fun givenRandomTestdata_writingToRedis_dataShouldBeAvailable() {
25+
given.randomTestdata()
26+
.whenRedis().isBeingWrittenTo()
27+
.then().redis().shouldContainTheTestdata()
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)