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

Slackbot

02/17/2021, 6:44 PM
This message was deleted.
m

Mustafa Ozhan

02/17/2021, 6:52 PM
Problem is not with your dependencies I think I made it work in my project recently please check the expect/actuals here: https://github.com/CurrencyConverterCalculator/CCC/blob/master/common/src/commonMain/kotlin/com/github/mustafaozhan/ccc/common/Expect.kt and you can check how I use in
client
module’s commonTest
d

Daniele B

02/17/2021, 10:28 PM
Hi @Mustafa Ozhan thanks! I tried to run your tests in
ApiRepositoryTest
, but I am getting an error:
Copy code
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':common:testDebugUnitTest'.
> Could not resolve all task dependencies for configuration ':common:debugUnitTestRuntimeClasspath'.
   > Could not resolve project :logmob.
     Required by:
         project :common
      > No matching configuration of project :logmob was found. The consumer was configured to find a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
          - None of the consumable configurations have attributes.
I tried to use the expect/actual functions of
runTest
on my project, but I still get this error:
Copy code
Exception in thread "Test worker @coroutine#1" java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android' and ensure it has the same version as 'kotlinx-coroutines-core'
m

Mustafa Ozhan

02/17/2021, 10:53 PM
Ohh I see your problem • first thins is first, so I use submodules, you will need to download them too so cloning should be like this
Copy code
git clone <https://github.com/CurrencyConverterCalculator/CCC.git>
cd CCC
git submodule update --init --recursive
• secondly after that change in
ApiFactory
these 2 lines
Copy code
takeFrom(BASE_URL_BACKEND)
...
takeFrom(BASE_URL_API)
please replace them with
""
otherwise you will get error that they are not committed to git
in which task your
runTest
is failing exactly ?
d

Daniele B

02/17/2021, 11:21 PM
I was able to run the tests on your project. And they work!
I am running
testDebugUnitTest
, simply selecting it with the right click on the function. But unfortunately mine don’t work. I still don’t understand why. The
runTest
definitions are exactly the same as yours.
I finally found the problem!!! In my test I was instantiating an object which was starting another coroutines on “init”, so that was conflicting! totally unrelated to
runTest
!!! Thanks for your support!
m

Mustafa Ozhan

02/18/2021, 8:18 AM
No worries you are welcome 🙂 I am glad that it is resolved!
10 Views