I need to write a short test for some Java code. I used CTRL + SHIFT + T to generate one with IntelliJ and selected "Groovy JUnit" as the test library, then wrote the following test:
package util class FibonacciHeapTest extends GroovyTestCase { FibonacciHeap<Integer> heap void setUp() { super.setUp() heap = new FibonacciHeap<>() } void testAddInOrder() { testForItems 1..1000 } private void testForItems(Range<Integer> items) { items.each {heap << it} assertEquals heap.size, items.to items.each {assertEquals heap.remove(), it} } }
However, when I right-click on a test case in the project window, I do not get the Run All Tests option, which I usually do with JUnit tests, and the compiler generates the following error:
Information:2/4/15 8:15 PM - Compilation completed with 2 errors and 0 warnings in 2 sec /home/patrick/IdeaProjects/hackerrank/src/test/java/util/FibonacciHeapTest.groovy Error:(3, 1) Groovyc: unable to resolve class util.FibonacciHeap Error:(9, 1) Groovyc: unable to resolve class GroovyTestCase
Attempting to import GroovyTestCase or FibonacciHeap manually causes the same error. IntelliJ does not add any import statements when I let autocomplete end names for me, as is usually the case with Java code.
What am I doing wrong?
java intellij-idea junit groovy
Patrick collins
source share