robstoll / atrium

A multiplatform expectation library for Kotlin
https://docs.atriumlib.org
European Union Public License 1.2
565 stars 209 forks source link

Support generating native library #450

Open dalewking opened 4 years ago

dalewking commented 4 years ago

Platform: iOS

Non-Code related feature

Unfortunately, I have to abandon Atrium because of the lack of support for Kotlin native for iOS. Kotlin multiplatform does not just mean Java and Javascript

robstoll commented 4 years ago

Thanks for bringing this one up. So far I did not get any feedback that people would like to use Atrium for iOS or another native platform. I will look into it once I have a use case myself (none in the outlook so far though). Please react with :+1: if you would like to see this implemented as well - this might motivate me to look into it even before I have a use case myself -- feel free to sponsor me, that would be a motivation too. And of course, your help would be appreciated.

Sxtanna commented 3 years ago

Please update this with native support. It's a great framework and it really sucks not having the ability to run tests on native.

robstoll commented 3 years ago

@Sxtanna thanks for the feedback. In case you have time and would like to contribute, we first need to migrate Atrium to the new MPP plugin in order to be able to provide native targets.

Sxtanna commented 3 years ago

@robstoll I am actually using this in my first ever mpp project, so I'm not too versed in all norms.

But I would be more than happy to prototype migration efforts. I'll give it a try.

robstoll commented 3 years ago

@Sxtanna great, I suggest you have a look at https://github.com/robstoll/atrium/issues/744 first. I'll try to help you so that you can do already some part of the migration. Migrating everything at once will probably a bit too much to start with. I'll see how we can do it best and come back to you again.

dalewking commented 3 years ago

Alternatively, kotest already has a nice assertion library that supports MPP.

robstoll commented 1 year ago

@Sxtanna MPP migration is done. would you like to add further platforms?

vivek-mittal commented 1 year ago

@robstoll is iOS/native support available now?

robstoll commented 1 year ago

No not yet, do you fancy to contribute it?

vivek-mittal commented 1 year ago

Love to. What would that entail?

robstoll commented 1 year ago

I see the following things which need to be done for each target platform. I suggest you start only with one of the tier 1 platforms. We can add more later: https://kotlinlang.org/docs/native-target-support.html

  1. you need to define them in build.gradle.kts -- I suggest you add it after js => https://github.com/robstoll/atrium/blob/main/build.gradle.kts#L137 (see https://kotlinlang.org/docs/multiplatform-set-up-targets.html for help)
  2. run ./gradlew build, you will get a few compilation errors because you need to implement expect definitions (I think we only have them in atrium-core) => take a look at JS we have sometimes defined reasonable defaults and I think in some cases we even throw an UnsupportedOperation (so far we never had complaints so I guess those features are not used by JS users) 2b. in case Spek does not support your native target, then you will have to provide a few dummy implementations so that it compiles in the end => see misc/atrium-specs/src/jsMain/kotlin/io.mockk/mock.kt as a guidance, Mockk does not support js and we just faked it for JS to make it run (spek also doesn't support JS)
  3. once it compiles, modify ch.tutteli.atrium.api.fluent.en_GB.samples.AnyExpectationSamples => toEqual, make it fail
  4. run ./gradlew :atrium-api-fluent-en_GB:xyTest where you need to replace xy with your platform name => we want to be sure that the samples are run for the new platform. This way we have at least a minimal test set in case Spek does not support the native target.
  5. in case Spek supports the native target, then modify for instance ch.tutteli.atrium.specs.integration.AnyExpectationsSpec and run again ./gradlew :atrium-api-fluent-en_GB:xyTest to see if it also fails for your native target

I hope this gives you good pointers to start. Maybe also take a look at https://github.com/robstoll/atrium/blob/main/.github/CONTRIBUTING.md#your-first-code-contribution

And in case you get stuck somewhere, create a draft PR and I'll try to help.