https://kotlinlang.org logo
#getting-started
Title
# getting-started
d

DMITRY.

07/17/2021, 2:28 PM
Hello! Is it possible to write tests in the same file as a function? I want to organize my solutions for the tasks I solve on Codewars Something like this:
I don't mind using something else other than JUnit
s

Sourabh Rawat

07/17/2021, 4:56 PM
If it's just for archiving your solutions, you can write the function in the test sourset in the same file as the test.
✔️ 1
c

CLOVIS

07/17/2021, 9:14 PM
In a real project, that is not a good idea. For small scripts/prototypes, you can just name your test main and execute it normally
✔️ 1
e

ephemient

07/18/2021, 1:43 AM
it would be interesting to have something doctest-like for Kotlin, but it doesn't exist now
👍 1
4 Views