Tina Hildebrandt
Tina Hildebrandt

Reputation: 1357

How to run Kotlin Koans in IntelliJ? What is the "Main class"?

I have downloaded Kotlin Koans from Github, installed IntelliJ IDEA 2016.1.3 and opened the Koans project. As I understand I need a Configuration to run the examples. This Configuration needs a Main class. I cannot figure out where I find the main class in the Kotlin Koans. I have searched for one but found none (except for a special one in htmlDemo.kt).

I see that some kind of unit test framework is used. It probably somehow calls task0 but the IDE shows no references to task0 except one from todoTask0. The only reference to todoTask0 is in task0. So we have circular references but nowhere do I find an external reference to call up one of these functions.

Can someone explain to me how to get the Kotlin Koans running in the IntelliJ IDE?

Upvotes: 16

Views: 6027

Answers (5)

Francislainy Campos
Francislainy Campos

Reputation: 4164

You can run them by clicking the Check Task button. :)

enter image description here

Upvotes: 0

Tsunhua
Tsunhua

Reputation: 59

In my case, it is the zsh's bug, can be solved in following:

  1. add setopt no_nomatch in the end of file ~/.zshrc;
  2. then run source /.zshrc

Upvotes: 0

ChristophE
ChristophE

Reputation: 873

already quite old question but I also struggled a bit. The way to do it is how they described it in their github repo (maybe they changed that since last time you checked)

https://github.com/Kotlin/kotlin-koans

How to build and run tests

Working with the project using Intellij IDEA or Android Studio:

Import the project as Gradle project. To build the project and run tests use 'test' task on Gradle panel.

What I did:

  1. Clone from github via File -> new project from version control -> github
  2. After that was done I also could not run anything
  3. File -> New Project from existing soure -> Choose your folder
  4. Import Project from external model -> choose Gradle
  5. No need to change anything, after that it worked for me

Upvotes: 4

awesoon
awesoon

Reputation: 33691

The easiest way is to install the Kotlin Edu plugin. You may read this JB blog post for additional info.

You could also run all koans tests without the plugin.IDEA allows you to run applications and tests directly from the IDE by clicking the Run icon near the test or application definition:

enter image description here

Upvotes: 6

miensol
miensol

Reputation: 41658

Follow the documentation:

  1. Open up the project in IntelliJ IDEA or your favorite editor. Note: If IntelliJ IDEA prompts you to update the Kotlin library, just click yes.

  2. Run a test. Make it pass

You can trigger a test run by opening a file (i.e kotlin-koans/test/i_introduction/_0_Hello_World/_00_Start.kt) and hitting: enter image description here

You can find more information about running tests in IntelliJ in the documentation.

Upvotes: 3

Related Questions