Run as JUnit test not Grails test?

Hi,

I've been using IDEA 7.0.3 + JetGroovy for a while doing Grails work and it's been great - thanks!

Anyway I upgraded to IDEA 8 and now when I create a new test class which indirectly (via my own class) extends GroovyTestCase, then right click, instead of creating a JUnit test configuration it creates a Grails Test configuration (or something like that), and when I run it, it's run via the grails command line!

Seems like JetGroovy should be able to recognise this is a simple Junit compatible test and run it with IDEA's Junit test runner. That was how it used to work in 7.0.3 anyway.

Cheers,
Maurice

8 comments
Comment actions Permalink

Hello, Maurice.

Yes, it's not bug but feature. If you try to run your Grails unit or integration tests, you can choose "Grails Test configuration" as an alternative to common JUint or TestNG. In such case your tests will be run using appropriate Grails script.
It was done to provide possibility to use Grails-context specific methods, like dynamic finders in Domain class. For now the won't work correctly with default JUnit runner, but will do with Grails Test runner.
Unfortunately we didn't manage to provide nice UI for such tests for Diana, cause it demands for full IDEA TestRunner rewriting but, I believe we'll do it for 8.0.1.
So, if you don't use Grails domain class features or something specific, you man run your tests vie JUnit as usual.

With best regards,
Ilya

0
Comment actions Permalink

Ok, I've changed a bit this behavior. Now if you invoke test run configuration creation on test method in such context, JUnit configuration will be created, cause Grails Test Runner doesn't provide test method atomicity level.

With best regards,
Ilya

0
Comment actions Permalink

Hi Ilya,

Well, what I find really convenient and what I preferred in the previous version was that I could write a JUnit test and literally right-click or (Ctrl-F10 is it, can't remember) and just run it, without needing to manually create a test run configuration.

So does your change help with this?

Actually these tests I have are not within the standard Grails test location, ie, mygrailsapp/test/unit or test/integration...

I have a lot of Java code in the my Grails app which I like to test independently of Grails.

So I have another directory (under mygrailsapp/src/test/...), where I keep my own plain old JUnit tests.

And a non-standard Ant file that perform the build.

The tests are written in Groovy because Groovy is great for unit testing, but they're not Grails tests per se.

So maybe the plugin could determine whether to create the Grails Test vs JUnit configuration depending on whether the code is under the normal Grails test dir?

Cheers,
Maurice

0
Comment actions Permalink

Ok, I think, you're right. So, if the test class is not under specific Grails test directory, only JUnit runner will be invoked. Grails test configuration will be default only for Grails specific tests.
These changes will be available in next minor Diana release.

With best regards,
Ilya

0
Comment actions Permalink

Awesome! Thanks :)

0
Comment actions Permalink

Ok, I think, you're right. So, if the test class is not under specific Grails test directory, only JUnit runner will be invoked. Grails test configuration will be default only for Grails specific tests.
These changes will be available in next minor Diana release.

With best regards,
Ilya


i got the same problem and found this thread.

it's good if the Grails test has a better runner ui. I suppose it won't happen over night. so, anyway, is it possible to have an option to run any test case that are not extending GrailsUnitTestCase (which is the standard way to create Grails unit test) to run with the original unit test runner? or allow us to set the default test runner for all test case to the old test runner?

The Grails test script may be broken. I make a simple test with fail() and the script still say all tests are passed! And it is not as fast as the old test runner. it's not useful to me.

regards,
mingfai

0
Comment actions Permalink

Ok, I think, you're right. So, if the test class is not under specific Grails test directory, only JUnit runner will be invoked. Grails test configuration will be default only for Grails specific tests.
These changes will be available in next minor Diana release.

With best regards,
Ilya


i got the same problem and found this thread.

it's good if the Grails test has a better runner ui. I suppose it won't happen over night. so, anyway, is it possible to have an option to run any test case that are not extending GrailsUnitTestCase (which is the standard way to create Grails unit test) to run with the original unit test runner? or allow us to set the default test runner for all test case to the old test runner?

The Grails test script may be broken. I make a simple test with fail() and the script still say all tests are passed! And it is not as fast as the old test runner. it's not useful to me.

regards,
mingfai


oh.. you mean "will"... i've just tried to move the Test class to other directory (e.g. /srcTest/unit) and the Grails test runner is still the default option for Run Context Configuration (Ctrl-Shift-F10) it seems there is no way other than the manually creating a JUnit configuration per class, right?

0
Comment actions Permalink

It will be fixed in next 8.1 EAP

0

Please sign in to leave a comment.