1

I'm trying to follow the code in this tutorial: http://www.vogella.com/tutorials/JUnit/article.html

However, that uses Eclipse and I'm using the trial version of IntelliJ (I found Eclipse on Ubuntu to be unusably prone to crashing.) I've followed the instructions for adding junit to my classpath in intelliJ, and it's showing up under "external libraries". However, the statement

import static org.junit.Assert.*;

is still greeted with "Cannot resolve symbol 'Assert'." Incidentally, when I click on the red "Test" annotations and hit alt-T, this brings up the option to add TestNG but NOT JUnit to the classpath, presumably because JUnit is already there...

rwold
  • 2,216
  • 1
  • 14
  • 22
  • 2
    Are you using any build system (maven, gradle, etc.. )? Or do you have the dependencies unmanaged? – pedromss Dec 06 '16 at 15:43
  • 1
    Click File->Project Structure->Libraries, and add JUnit. – walsh Dec 06 '16 at 15:53
  • @pedromss I'm managing the dependencies manually. – rwold Dec 06 '16 at 22:53
  • @walsh As I mentioned in the post, I have added JUnit. I originally tried doing so via the lightbulb that appeared next to my Test annotation; when it wasn't working I tried doing it in exactly the way you suggest. – rwold Dec 06 '16 at 22:57
  • Possible duplicate of [Configuring IntelliJ IDEA for unit testing with JUnit](http://stackoverflow.com/questions/4757800/configuring-intellij-idea-for-unit-testing-with-junit) – Stefan Birkner Dec 07 '16 at 05:57
  • @StefanBirkner I don't feel this is a duplicate of that thread- I read that thread before posting this. There the user didn't know how to add the jars; I couldn't get mine working despite adding them... – rwold Dec 11 '16 at 23:55

1 Answers1

0

I created a clean project, this time importing junit before writing the classes, and it worked perfectly. Such is life...

rwold
  • 2,216
  • 1
  • 14
  • 22