Hi, does anyone have any hacks or tips to get `kot...
# amper
a
Hi, does anyone have any hacks or tips to get
kotest
to work with amper? For me it’s reporting something like “no test classes found”
a
could you please share the project if it's possible? (works on my machine :DDDDD) (c) TM
j
Could you please describe how exactly you run things? Maybe share a reproducer project?
Jinx 🙂
🙃 1
a
I found one problem, but maybe more (upd: link was wrong, now it's correct one)
s
I am also getting
no test were discoverd error
even though tests are there in shared/test folder
Copy code
$ ./amper test 
...
 00:03.401 WARN  :jvm:testJvm              No test classes, skipping test execution for module 'jvm'
    00:06.454 INFO  :shared:testJvm           Testing module 'shared' for platform 'jvm'...
    ERROR: JVM tests failed for module 'shared' with exit code 2 (no tests were discovered) (see errors above)
By the way, in amper, should a test run as part of a build/package or do we need to explicitly invoke it?
j
> I am also getting
no test were discoverd error
even though tests are there in shared/test folder I believe you might be running into the common issue that the defaults of the JUnit Console launcher (which we're using) is to filter only test classes that start or end with
Test
or
Tests
. This is a bit confusing and we might change it. Could you please confirm whether your test classes were missing such suffix/prefix? Do you get the same issue if you rename your classes to add such suffixes/prefixes?
By the way, in amper, should a test run as part of a build/package or do we need to explicitly invoke it?
In Amper we decided that the
build
command was only for building (initially we even called it
compile
to avoid confusion with Gradle semantics).
./amper test
will of course compile before testing. So yes, you do need to call
./amper test
if your goal is to run tests.
s
shared/test/test.kt
Copy code
import kotlin.test.Test
import kotlin.test.assertTrue

class WorldTest {
  @Test
  fun doTest() {
    assertTrue(World().get().contains("World"))
  }
}
This is generated by the default multiplatform cli amper template.
The tests are running for native target
j
Strange. These JVM tests work for me locally:
Copy code
00:03.152 INFO  :shared:compileMingwX64Debug Downloading <https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-native-prebuilt/2.2.0/kotlin-native-prebuilt-2.2.0-windows-x86_64.zip> to C:\Users\Joffrey.Bion\AppData\Local\JetBrains\Amper\download.cache\90f79a2489-kotlin-native-prebuilt-2.2.0-windows-x86_64.zip
00:03.808 INFO  :shared:compileJvm        Compiling module 'shared' for platform 'jvm'...
00:07.650 WARN  :shared:compileJvm        file:///D:/projects/TESTS/kmp-cli/shared/src/World.kt:1:1 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta. Consider using the '-Xexpect-actual-classes' flag to suppress this warning. Also see: <https://youtrack.jetbrains.com/issue/KT-61573>
00:07.650 WARN  :shared:compileJvm        file:///D:/projects/TESTS/kmp-cli/shared/src@jvm/World.kt:1:1 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta. Consider using the '-Xexpect-actual-classes' flag to suppress this warning. Also see: <https://youtrack.jetbrains.com/issue/KT-61573>
00:07.678 INFO  :shared:compileJvmTest    Compiling module 'shared' for platform 'jvm'...
00:07.686 WARN  :jvm-cli:testJvm          No test classes, skipping test execution for module 'jvm-cli'
00:08.215 INFO  :shared:testJvm           Testing module 'shared' for platform 'jvm'...
Started WorldTest
Started doTest()
Passed doTest()

Test run finished after 178 ms
[         4 containers found      ]
[         0 containers skipped    ]
[         4 containers started    ]
[         0 containers aborted    ]
[         4 containers successful ]
[         0 containers failed     ]
[         1 tests found           ]
[         0 tests skipped         ]
[         1 tests started         ]
[         0 tests aborted         ]
[         1 tests successful      ]

00:09.679 INFO  :shared:compileMingwX64Debug Extracting C:\Users\Joffrey.Bion\AppData\Local\JetBrains\Amper\download.cache\90f79a2489-kotlin-native-prebuilt-2.2.0-windows-x86_64.zip to C:\Users\00:24.615 INFO  :shared:compileMingwX64Debug Compiling module 'shared' for platform 'mingwX64'...
00:30.834 ERROR :shared:compileMingwX64Debug D:\projects\TESTS\kmp-cli\shared\src\World.kt:1:1: warning: 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta. Consider using the '-Xexpect-actual-classes' flag to suppress this warning. Also see: <https://youtrack.jetbrains.com/issue/KT-61573>
00:30.834 ERROR :shared:compileMingwX64Debug expect class World() {
00:30.849 ERROR :shared:compileMingwX64Debug ^^^^^^
00:30.849 ERROR :shared:compileMingwX64Debug D:\projects\TESTS\kmp-cli\shared\src@mingw\World.kt:1:1: warning: 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta. Consider using the '-Xexpect-actual-classes' flag to suppress this warning. Also see: <https://youtrack.jetbrains.com/issue/KT-61573>
00:30.850 ERROR :shared:compileMingwX64Debug actual class World {
00:30.850 ERROR :shared:compileMingwX64Debug ^^^^^^
00:30.867 INFO  :windows-cli:linkMingwX64TestDebug No test code was found compiled for fragments [commonTest, mingwTest, mingwX64Test, nativeTest] of module 'windows-cli', skipping linking
00:30.867 INFO  :windows-cli:testMingwX64Debug No test binary was found for mingwX64, skipping test run
00:30.884 INFO  :shared:compileMingwX64TestDebug Compiling module 'shared' for platform 'mingwX64'...
00:42.017 INFO  :shared:testMingwX64Debug Testing module 'shared' for platform 'mingwX64'...
[==========] Running 1 tests from 1 test cases.
[----------] Global test environment set-up.
[----------] 1 tests from WorldTest
[ RUN      ] WorldTest.doTest
[       OK ] WorldTest.doTest (0 ms)

[----------] Global test environment tear-down
[==========] 1 tests from 1 test cases ran. (0 ms total)
[  PASSED  ] 1 tests.
(by the way, I'll remove these nasty warnings about expect/actual classes, sorry about this)
Are you using any test filters (CLI options)? Or literally running just
./amper test
?
a
Problem seems to be gone now, amper does pick up the tests. I will do some more research. I do notice that the green gutter arrows show up (via kotest plugin i suppose), but they don’t wok: «Nothing here» The arrows work in gradle project, for running some specific test or suite.
s
@joffreyMy bad, i think it’s working as expected. The error was from testJvm, and I only have tests for shared/test. Sorry for the confusion.
Copy code
00:06.466 WARN  :jvm:testJvm              No test classes, skipping test execution for module 'jvm'
00:06.867 INFO  :shared:testJvm           Testing module 'shared' for platform 'jvm'...