mirror of
https://github.com/yuzono/anime-extensions.git
synced 2026-10-20 10:51:36 +00:00
[skip yuzono ci] Use JUnit 4 for every unit test
core's UrlUtilsTest imported kotlin.test, but core only declares libs.junit, so :core:compileDebugUnitTestKotlin failed. lib/unpacker used kotlin-test-junit instead, and src/en/hanime configured a test/ source directory and hardcoded test dependencies although no tests were ever committed there. Settle on JUnit, which NextJsTest (from upstream) and lib/megaextractor already use: switch UrlUtilsTest and the lib/unpacker tests to org.junit, declare libs.junit in lib/unpacker, and drop hanime's unused test setup. JUnit takes the assertion message first, so the 9 assertTrue/assertFalse calls in lib/unpacker that pass one have their arguments swapped. Only test code and configuration change, so nothing needs bumping or building. Without the prefix, CI would bump every extension that depends on lib/unpacker.
This commit is contained in:
@@ -29,13 +29,10 @@ Extensions have none – they are verified by compiling and running against the
|
||||
(`CONTRIBUTING.md#submitting-the-changes` ~ `1369`).
|
||||
|
||||
```bash
|
||||
./gradlew --continue :core:testDebugUnitTest :lib:unpacker:testDebugUnitTest :lib:megaextractor:testDebugUnitTest
|
||||
./gradlew :core:testDebugUnitTest --tests 'keiyoushi.utils.UrlUtilsTest'
|
||||
```
|
||||
|
||||
Known-broken: `:core:compileDebugUnitTestKotlin` fails – the tests import `kotlin.test.*` but
|
||||
`core/build.gradle.kts` only declares `testImplementation(libs.junit)`. Adding a `kotlin-test`
|
||||
dependency fixes it; until then the test task cannot run.
|
||||
|
||||
### Loading a subset of modules
|
||||
|
||||
`settings.gradle.kts` calls `loadAllIndividualExtensions()`, which includes every extension under
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package keiyoushi.utils
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class UrlUtilsTest {
|
||||
|
||||
|
||||
@@ -21,5 +21,5 @@ android {
|
||||
|
||||
dependencies {
|
||||
testImplementation(kotlin("stdlib"))
|
||||
testImplementation(kotlin("test-junit"))
|
||||
testImplementation(libs.junit)
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package keiyoushi.lib
|
||||
|
||||
import keiyoushi.lib.jsunpacker.JsUnpacker
|
||||
import keiyoushi.lib.unpacker.Unpacker
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
|
||||
class AutoUnpackerTest {
|
||||
@Test
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package keiyoushi.lib.jsunpacker
|
||||
|
||||
import keiyoushi.lib.autoUnpacker
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
|
||||
class AutoUnpackerJsUnpackerTest {
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package keiyoushi.lib.jsunpacker
|
||||
|
||||
import keiyoushi.lib.autoUnpacker
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
|
||||
class AutoUnpackerJsUnpackerUnitTest {
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package keiyoushi.lib.jsunpacker
|
||||
|
||||
import kotlin.collections.single
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
|
||||
class JsUnpackerTest {
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package keiyoushi.lib.jsunpacker
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
|
||||
/**
|
||||
* Taken from https://github.com/DatL4g/JsUnpacker/blob/master/src/commonTest/kotlin/dev/datlag/jsunpacker/UnpackUnitTest.kt
|
||||
@@ -11,28 +11,28 @@ class JsUnpackerUnitTest {
|
||||
|
||||
@Test
|
||||
fun callIsNotPacked() {
|
||||
assertFalse(JsUnpacker.detect(NOT_PACKED_CALL), "JsUnpacker detected not packed call as packed")
|
||||
assertFalse("JsUnpacker detected not packed call as packed", JsUnpacker.detect(NOT_PACKED_CALL))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun functionIsNotPacked() {
|
||||
assertFalse(JsUnpacker.detect(NOT_PACKED_FUNCTION), "JsUnpacker detected not packed function as packed")
|
||||
assertFalse("JsUnpacker detected not packed function as packed", JsUnpacker.detect(NOT_PACKED_FUNCTION))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun callIsPacked() {
|
||||
assertTrue(JsUnpacker.detect(PACKED_CALL), "JsUnpacker did not detect packed call as packed")
|
||||
assertTrue("JsUnpacker did not detect packed call as packed", JsUnpacker.detect(PACKED_CALL))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun functionIsPacked() {
|
||||
assertTrue(JsUnpacker.detect(PACKED_FUNCTION), "JsUnpacker did not detect packed function as packed")
|
||||
assertTrue("JsUnpacker did not detect packed function as packed", JsUnpacker.detect(PACKED_FUNCTION))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun callUnpackedCorrectly() {
|
||||
val unpacked = JsUnpacker.unpackAndCombine(PACKED_CALL)
|
||||
assertTrue(callUnpackCheck(unpacked), "JsUnpacker did not unpack call correctly")
|
||||
assertTrue("JsUnpacker did not unpack call correctly", callUnpackCheck(unpacked))
|
||||
}
|
||||
|
||||
private fun callUnpackCheck(unpacked: String?): Boolean = unpacked == UNPACKED_CALL || unpacked == UNPACKED_CALL_ALLOWED
|
||||
@@ -40,7 +40,7 @@ class JsUnpackerUnitTest {
|
||||
@Test
|
||||
fun functionUnpackedCorrectly() {
|
||||
val unpacked = JsUnpacker.unpackAndCombine(PACKED_FUNCTION)
|
||||
assertTrue(functionUnpackCheck(unpacked), "JsUnpacker did not unpack function correctly")
|
||||
assertTrue("JsUnpacker did not unpack function correctly", functionUnpackCheck(unpacked))
|
||||
}
|
||||
|
||||
private fun functionUnpackCheck(unpacked: String?): Boolean = unpacked == UNPACKED_FUNCTION || unpacked == UNPACKED_FUNCTION_ALLOWED
|
||||
@@ -48,7 +48,7 @@ class JsUnpackerUnitTest {
|
||||
@Test
|
||||
fun unpackMultipleCorrectly() {
|
||||
val (unpackedCall, unpackedFunction) = JsUnpacker.unpack(PACKED_CALL, PACKED_FUNCTION)
|
||||
assertTrue(callUnpackCheck(unpackedCall) && functionUnpackCheck(unpackedFunction), "JsUnpacker did not unpack call and function together correctly")
|
||||
assertTrue("JsUnpacker did not unpack call and function together correctly", callUnpackCheck(unpackedCall) && functionUnpackCheck(unpackedFunction))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package keiyoushi.lib.unpacker
|
||||
|
||||
import keiyoushi.lib.autoUnpacker
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
|
||||
class AutoUnpackerUnpackerTest {
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package keiyoushi.lib.unpacker
|
||||
|
||||
import keiyoushi.lib.autoUnpacker
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertTrue
|
||||
|
||||
class AutoUnpackerUnpackerUnitTest {
|
||||
|
||||
@Test
|
||||
fun callUnpackedCorrectly() {
|
||||
val unpacked = autoUnpacker(PACKED_CALL)
|
||||
assertTrue(callUnpackCheck(unpacked), "Unpacker did not unpack call correctly")
|
||||
assertTrue("Unpacker did not unpack call correctly", callUnpackCheck(unpacked))
|
||||
}
|
||||
|
||||
private fun callUnpackCheck(unpacked: String?): Boolean = unpacked == UNPACKED_CALL || unpacked == UNPACKED_CALL_ALLOWED
|
||||
@@ -17,7 +17,7 @@ class AutoUnpackerUnpackerUnitTest {
|
||||
@Test
|
||||
fun functionUnpackedCorrectly() {
|
||||
val unpacked = autoUnpacker(PACKED_FUNCTION)
|
||||
assertTrue(functionUnpackCheck(unpacked), "Unpacker did not unpack function correctly")
|
||||
assertTrue("Unpacker did not unpack function correctly", functionUnpackCheck(unpacked))
|
||||
}
|
||||
|
||||
private fun functionUnpackCheck(unpacked: String?): Boolean = unpacked == UNPACKED_FUNCTION || unpacked == UNPACKED_FUNCTION_ALLOWED
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package keiyoushi.lib.unpacker
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertEquals
|
||||
|
||||
class SubstringExtractorTest {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package keiyoushi.lib.unpacker
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertEquals
|
||||
|
||||
class UnpackerTest {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package keiyoushi.lib.unpacker
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.Assert.assertEquals
|
||||
|
||||
class UnpackerUnitTest {
|
||||
|
||||
|
||||
@@ -15,21 +15,8 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
// Unit tests live outside `src/` because the legacy plugin makes the
|
||||
// module-root `src` directory the MAIN source root.
|
||||
androidComponents {
|
||||
onVariants(selector().all()) { variant ->
|
||||
variant.unitTest?.sources?.java?.addStaticSourceDirectory(file("test").absolutePath)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":lib:playlistutils"))
|
||||
//noinspection UseTomlInstead
|
||||
implementation("com.dylibso.chicory:runtime:1.7.5")
|
||||
// kotlin.stdlib.default.dependency=false repo-wide; unit tests need it declared explicitly
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:${libs.versions.kotlin.gradle.get()}")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
// bundles.common is compileOnly, so source supertypes are missing from the unit-test runtime
|
||||
testRuntimeOnly("com.github.komikku-app:aniyomi-extensions-lib:bdc8184127")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user