-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing multiplatform code? #9
Comments
Hey Peter, thanks for opening the issue. When you mean multiplatform code, do you specifically have Kotlin's JS support in mind? Specnaz is actually structured into separate libraries. While there's a The only snag that I can potentially see with supporting JS is that the |
Multiplatform and JS - actually, Kotlin supports also native binaries, and maybe more platforms to come in the future. To better explain the vocabulary I use: when a project is created that is meant to target multiple patforms, some code can be made common for all or some platforms. I call such code platform-agnostic because it doesn't know about any platform it's compiled for (JVM, JS, linux's 64-bit binary, and so on). Also, such platform-agnostic code cannot be run on its own. Like an abstract class which cannot be instantiated, common Kotlin code needs to be ingested by some platform-specific project to be compiled/transpiled and run. To give you a concrete example what I'm working on, see my project https://github.com/krzema12/fsynth - the Looking at the project structure of Specnaz, Addressing your last paragraph: using Java to write platform-agnostic library to test Kotlin code would be pain... So probably it would have to be written in pure, platform-agnostic Kotlin, i.e. depending only on kotlin-stdlib's parts meant for "common" (see cyan dots). |
Thanks for the detailed explanation @krzema12! The reason I asked about the Java Kotlin multiplatform story is that the So, it seems like Do you have any ideas on how can this problem be solved? |
Sure, Kotlin runtime would have to exist in all platform-specific versions of Specnaz, in JVM and also e. g. in JS. That's the cost of this additional layer of abstraction. But I personally wouldn't call it not acceptable. Specnaz is a test library, and as a user I wouldn't mind having a more versatile library for the cost of the slightly bigger test runtime. That what probably happens for Having duplicated code is of course out of the question, it's an operational pain. It would be certainly possible to avoid it (actually that's what can be avoided with the platform-independent code). I glanced at other test libraries for Kotlin and they all target JVM. Maybe we should take a more in-depth look, and see if they plan to expand to multiplatform code, too. |
Perhaps my statement about adding the dependency being not acceptable was too strong :-). But I don't think it's free either. There is a reason that the Specnaz libraries don't depend on JUnit/TestNG/Kotlin's standard library currently. Also, the added versatility is irrelevant to Specnaz's Java users (which outnumber the Kotlin users), who would still pay the costs of the added dependency. I actually had a different idea of how to make this work, without adding the extra dependency. I thought that we could transpile the Java code in |
I'm not sure if I understood you correctly: you'd like to transpile Java code to Kotlin platform-independent code, right? I don't think it's doable - IntelliJ transpiles Java to Kotlin for JVM. It's easy because each Java entity can be called from within Kotlin if targeting JVM. For Kotlin platform-independent code, the transpiler would have to know how to come up with JVM feature "foobar" in the standard Kotlin platform-agnostic library, and it's impossible since only a subset of platforms' features is covered in this common library. I hope I understood you correctly and I didn't mess something up. I'm curious what JetBrains replies, maybe they'll propose yet another approach to the problem we're trying to solve here. |
Well, if it turns out you need JVM feature 'foobar' not present in the Kotlin platform-agnostic standard library to implement this |
I meant a bit different thing. Let's assume you use All of this may not be an issue in case of Specnaz, I'm just giving you a heads up what to expect if the approach proposed by you is chosen. |
For completeness, here are related issues in other testing frameworks for Kotlin: |
Issue opened to JetBrains: https://youtrack.jetbrains.com/issue/IDEA-202428 |
Hi there!
I was wondering: is specnaz ever going to support testing of platform-agnostic code? As far as I see, now it's coupled with JVM platform (JUnit/TestNG). When one wants to test a platform-agnostic Kotlin code, I guess we're stuck with
kotlin.test
for now. I'd love to be able to write these tests conveniently with specnaz!If you don't plan to support it, it would be nice to drop a sentence in the library description that it's solely for JVM.
Cheers!
The text was updated successfully, but these errors were encountered: