https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
r

ribesg

05/13/2019, 9:12 AM
I’m trying to run some tests on a MPP library (Android & iOS targets) and I have some questions. 1. Why do I need to have JUnit/JUnit5/TestNG on the Android part just to get the
@Test
annotation? 2. Can you have top-level tests instead of having to put them in a class? 3. Is there a good sample on how to have tests running for iOS, especially in the case of needing some CInterops?
1
On the iOS part, I’m currently stuck at getting the ObjC lib used by a dependency found inside the simulator. (So yeah I’m already at the part where it attempts to run something inside the simulator)
Copy code
> Task :iosTest FAILED
dyld: Library not loaded: @rpath/Bugsnag.framework/Bugsnag
  Referenced from: <project>/build/bin/iosSim/testDebugExecutable/test.kexe
  Reason: image not found
Child process terminated with signal 6: Abort trap

FAILURE: Build failed with an exception.
Copy code
ribesg:testDebugExecutable/ (develop✗) $ otool -L test.kexe                                                                          [12:26:27]
test.kexe:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1570.15.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	@rpath/Bugsnag.framework/Bugsnag (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation (compatibility version 150.0.0, current version 1570.15.0)
	/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 400.17.0)
s

svyatoslav.scherbina

05/13/2019, 10:34 AM
dyld: Library not loaded: @rpath/Bugsnag.framework/Bugsnag
It is likely missing at location where
test.kexe
expects to find it, i.e.
<project>/build/bin/iosSim/testDebugExecutable/Frameworks/Bugsnag.framework/Bugsnag
r

ribesg

05/13/2019, 10:35 AM
Oh, so I need to copy it? Is it possible to replace this
@rpath
? Wait it may not be a good idea to travel outside of
testDebugExecutable
s

svyatoslav.scherbina

05/13/2019, 10:37 AM
You can copy both framework and executable to other location.
r

ribesg

05/13/2019, 10:39 AM
Yeah I need both of them in the same place, but I guess than copying the framework from the Carthage build directory to the
testDebugExecutable
directory makes more sense than the other way around
Ok I have tests running!
r

russhwolf

05/13/2019, 11:55 AM
1. The
kotlin.test.Test
annotation on the JVM is just a typealias, so you need to include junit or testng to provide the actual implementation.
r

ribesg

05/13/2019, 11:57 AM
Yes, but why do we need that? We can’t use the rest of JUnit/TestNG in our tests anyway!
r

russhwolf

05/13/2019, 12:50 PM
I think it's because you still need to select what implementation to use under the hood. And you might interop with existing test code you have written in one of those frameworks. A lot of multiplatform is not building new implementations from scratch, but rather wrapping existing things in a common API.
r

ribesg

05/13/2019, 12:52 PM
Sure, but there is an implementation for native and js, right? There should be something like
kotlin-test-jvm
providing the same implementations than for js and native. I understand that it can’t be in common because you can’t override actuals but I don’t understand that it doesn’t exist at all.
7 Views