Skip to content

Commit 0b44a36

Browse files
committed
[ECO-5338] Created unit/integration test package for liveobjects
1. Updated separate gradlew task for both unit and integration tests 2. Updated check.yml and integration-test.yml file to run respective tests
1 parent f61cc6a commit 0b44a36

File tree

6 files changed

+78
-9
lines changed

6 files changed

+78
-9
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
distribution: 'temurin'
2020
- name: Set up Gradle
2121
uses: gradle/actions/setup-gradle@v3
22-
- run: ./gradlew checkWithCodenarc checkstyleMain checkstyleTest runUnitTests
22+
- run: ./gradlew checkWithCodenarc checkstyleMain checkstyleTest runUnitTests runLiveObjectUnitTests

.github/workflows/integration-test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,21 @@ jobs:
9090
uses: gradle/actions/setup-gradle@v3
9191

9292
- run: ./gradlew :java:testRealtimeSuite -Pokhttp
93+
94+
check-liveobjects:
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/checkout@v4
98+
with:
99+
submodules: 'recursive'
100+
101+
- name: Set up the JDK
102+
uses: actions/setup-java@v4
103+
with:
104+
java-version: '17'
105+
distribution: 'temurin'
106+
107+
- name: Set up Gradle
108+
uses: gradle/actions/setup-gradle@v3
109+
110+
- run: ./gradlew runLiveObjectIntegrationTests

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jetbrains = { group = "org.jetbrains", name = "annotations", version.ref = "jetb
5555
[bundles]
5656
common = ["msgpack", "vcdiff-core"]
5757
tests = ["junit", "hamcrest-all", "nanohttpd", "nanohttpd-nanolets", "nanohttpd-websocket", "mockito-core", "concurrentunit", "slf4j-simple"]
58+
kotlin-tests = ["junit", "mockk", "coroutine-test", "nanohttpd", "turbine"]
5859
instrumental-android = ["android-test-runner", "android-test-rules", "dexmaker", "dexmaker-dx", "dexmaker-mockito", "android-retrostreams"]
5960

6061
[plugins]

live-objects/build.gradle.kts

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2+
13
plugins {
24
`java-library`
35
alias(libs.plugins.kotlin.jvm)
6+
alias(libs.plugins.test.retry)
47
}
58

69
repositories {
@@ -9,18 +12,37 @@ repositories {
912

1013
dependencies {
1114
implementation(project(":java"))
12-
testImplementation(kotlin("test"))
1315
implementation(libs.coroutine.core)
1416

15-
testImplementation(libs.junit)
16-
testImplementation(libs.mockk)
17-
testImplementation(libs.coroutine.test)
18-
testImplementation(libs.nanohttpd)
19-
testImplementation(libs.turbine)
17+
testImplementation(kotlin("test"))
18+
testImplementation(libs.bundles.kotlin.tests)
19+
}
20+
21+
tasks.withType<Test>().configureEach {
22+
testLogging {
23+
exceptionFormat = TestExceptionFormat.FULL
24+
}
25+
jvmArgs("--add-opens", "java.base/java.time=ALL-UNNAMED")
26+
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
27+
beforeTest(closureOf<TestDescriptor> { logger.lifecycle("-> $this") })
28+
outputs.upToDateWhen { false }
29+
// Skip tests for the "release" build type so we don't run tests twice
30+
if (name.lowercase().contains("release")) {
31+
enabled = false
32+
}
33+
}
34+
35+
tasks.register<Test>("runLiveObjectUnitTests") {
36+
filter {
37+
includeTestsMatching("io.ably.lib.objects.unit.*")
38+
}
2039
}
2140

22-
tasks.test {
23-
useJUnitPlatform()
41+
tasks.register<Test>("runLiveObjectIntegrationTests") {
42+
filter {
43+
includeTestsMatching("io.ably.lib.objects.integration.*")
44+
}
45+
// TODO - check if we need retry mechanism for integration tests in the future
2446
}
2547

2648
kotlin {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.ably.lib.objects.integration
2+
3+
import org.junit.Assert.assertTrue
4+
import org.junit.Test
5+
6+
class LiveObjectTest {
7+
8+
@Test
9+
fun testLiveObjectCreationIntegrationTest() {
10+
// This is a placeholder for the actual test implementation.
11+
// You would typically create instances of LiveObjects and perform assertions here.
12+
assertTrue(true)
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.ably.lib.objects.unit
2+
3+
import org.junit.Assert.assertTrue
4+
import org.junit.Test
5+
6+
class LiveObjectTest {
7+
8+
@Test
9+
fun testLiveObjectCreationUnitTest() {
10+
// This is a placeholder for the actual test implementation.
11+
// You would typically create instances of LiveObjects and perform assertions here.
12+
assertTrue(true)
13+
}
14+
}

0 commit comments

Comments
 (0)