2

New to groovy and java. Installed groovy,plugin with eclipse and created a groovy project
I am able to run groovy scripts and groovy class. But GroovyTestCase class is not getting resolved. Any help is appreciated.

package p1
import groovy.util.GroovyTestCase

class MyTest extends GroovyTestCase { //GroovyTestCase keyword is showing this error: type junit.framework.TestCase cannot be resolved.  It is indirectly referred from required .class files

    void testSomething() {
        assert 1 == 1
        assert 2 + 2 == 4 : "We're in trouble, arithmetic is broken"
    }
}

2 Answers 2

4

GroovyTestCase is JUnit 3, If you want to use Junit4, don't extend the class, instead use the @Test annotations like in Java.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use JUnit as it was pointed out before, but on Groovy usually the library that it is used it is called Spock. Next question would be Why Spock, then check this out.

We have been using it for a while, and it works like a charm. Highly recommended.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.