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

Ray Rahke

03/12/2024, 6:34 PM
How can I do unit testing without the use of gradle/maven
j

Joffrey

03/12/2024, 6:40 PM
You'll have to manually compile your main and test classes with some test framework (like JUnit) on the classpath, and then use your test framework runner to run your test classes. For instance with JUnit 5: https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher
But what are you trying to do with this? It's usually much simpler to run tests using a build tool
r

Ray Rahke

03/12/2024, 6:42 PM
I am trying to do projects from scratch in vscode, and setting up anything related to gradle seems like it's going to take up an entire afternoon of reading dry documentation
just wanting to write some quick kotlin scripts, and be able to test them while doing so.
j

Joffrey

03/12/2024, 6:42 PM
Setting up things without Gradle is most likely going to require much more than one afternoon if you're not familiar with the ecosystem 🙂
👍 1
r

Ray Rahke

03/12/2024, 6:42 PM
yeah
I meant though
without using JUnit even
is there any technique I can do for writing tests
j

Joffrey

03/12/2024, 6:45 PM
I don't know of any approach that will not amount to implementing your own test framework
k

Klitos Kyriacou

03/12/2024, 6:52 PM
Well you could write your tests in
fun main
and use
check
as your assertion library, but a proper test framework offers you so much more.
👍 1
a

Adam S

03/12/2024, 9:02 PM
JUnit has a console launcher - but it's going to be easier to use Maven or Gradle for sure https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher