5

Warning: I'm a huge noob to TDD and Kotlin.

I've found good code snippets on the web for writing JUnit tests in Kotlin, but when I copy and paste, IntelliJ does not automagically import kotlin.test.* or org.junit.Test. Typically in Eclipse, when I copy and paste code snippets like this, the IDE can figure out where these libraries are in my underlying java install. Figured Kotlin/IntelliJ would be the same.

In the below screenshot, any idea why I cannot import test libraries? Do they need to be added explicitly to my path? Do I need to put these under a test, rather than the src folder?

Thanks enter image description here

Adam Hughes
  • 14,601
  • 12
  • 83
  • 122
  • And hint: no need for a screenshot - you could as well just post the code and the error message as text ... just saying. – GhostCat Feb 13 '17 at 19:47
  • 2
    Thanks, sometimes I think for questions involving an editor, it's easier to show the editor's color highlighting and so forth instead of just my code. – Adam Hughes May 31 '17 at 13:32

1 Answers1

6

JUnit isn't in your project classpath, so IntelliJ can't find it's packages.

Follow the steps outlined in this answer: Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project, choosing libraries and then junit.

Community
  • 1
  • 1