This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I cannot run any unit test written in Groovy. "Run -> Test File" is grayed out (so is "Run -> Compile File"). "Run -> Test Project" gives "no tests executed". Tried with JUnit 3 extending TestCase, JUnit 3 extending GroovyTestCase, JUnit 4 with @Test, and JUnit 4 with custom @RunWith runner but without @Test (the latter is what I really need). "Run -> Run Project" seems to work, at least for HelloWorld.groovy.
Run/Test file from context menu works for me. I'll investigate further.
I've tried again with 6.7 RC1, but still no luck. Run -> Test File is grayed out. Run -> Run File is enabled, but reports "No tests executed". Here is my test class (it's both a GroovyTestCase and a JUnit 4 test at the same time): package netbeansgroovytest import org.junit.Test class GroovyTest extends GroovyTestCase { @Test void testMe() { println "HIIIIIIIIIIII" assert false } }
Tried again with 6.7 final, and I still can't run any unit test. Also I get exceptions when creating new Groovy classes, editor sometimes doesn't recognize Groovy files (I get a plain text editor), etc. etc. It's a pity but the Netbeans Groovy plugin is totally unusable.
Reproduced. There is a problem with ant integration.
P3 means no JUnit support in 6.8?
Not sure if I'm able to reproduce original issue, but it seems to me that we have a problem with running tests for Groovy in general. I've created simple Java project with one Java JUnit test and one Groovy test and when trying to Run/Test those files, there is no test result shown in JUnit runner panel. This should be fixed. Setting TM --> 7.2
Moving to Editor component
For now if you need at least a workarround to able to run .groovy tests, you need to change your build.xml file and put these lines right behind import line: <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run"> <j2seproject3:junit testincludes="**/*Test.class"/> </target> <target name="-init-macrodef-junit"> <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${includes}" name="includes"/> <attribute default="${excludes}" name="excludes"/> <attribute default="**" name="testincludes"/> <sequential> <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true"> <batchtest todir="${build.test.results.dir}"> <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> <filename name="@{testincludes}"/> </fileset> </batchtest> <classpath> <path path="${run.test.classpath}"/> </classpath> <syspropertyset> <propertyref prefix="test-sys-prop."/> <mapper from="test-sys-prop.*" to="*" type="glob"/> </syspropertyset> <formatter type="brief" usefile="false"/> <formatter type="xml"/> <jvmarg line="${run.jvmargs}"/> </junit> </sequential> </macrodef> </target> Note that it has also some unpleasant side effects (for example you will not be able to Run single test). I'm working on fix right now..
After adding the code from above I get: /home/fb/projects/BGB/build.xml:15: The prefix "j2seproject3" for element "j2seproject3:junit" is not bound. any suggestions?
Ye, my apologize. I forgot to tell that you also need to change root project element and add this attribute: xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" ..which means element might looks like: <project name="TestGroovy" default="default" basedir="." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3">
Created attachment 119676 [details] build-impl.xml patch
I've attached new build-impl.xml patch. After the changes both Java and Groovy tests should work together in Ant based projects. It also solves the side effect problem with running single method test. Can't say now if would be possible to integrate those changes into the 7.2.
I was looking at Maven projects as well. It's actually much more easier to get Groovy tests working in Maven based projects - there are few things that you need to do: 1] Add groovy dependency to pom.xml: <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.8.6</version> </dependency> 2] Add Groovy-Eclipse compiler plugin for maven[1] to pom.xml: <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <compilerId>groovy-eclipse-compiler</compilerId> <verbose>true</verbose> </configuration> <dependencies> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-compiler</artifactId> <version>2.6.0-01</version> </dependency> </dependencies> </plugin> </plugins> </build> 3] Create folder in src/test/groovy/.. and create some Groovy JUnit test inside --> As a result you should be able to run those Groovy JUnit tests together with standard Java JUnit tests [1] Groovy-Eclipse compiler plugin for maven: http://docs.codehaus.org/display/GROOVY/Groovy-Eclipse+compiler+plugin+for+Maven#Groovy-EclipsecompilerpluginforMaven-Howtousethecompilerplugin---SettingupthePOM
Fixed in: http://hg.netbeans.org/web-main/rev/234fbe2524b6 http://hg.netbeans.org/web-main/rev/c119f27b6f29 http://hg.netbeans.org/web-main/rev/d3a4378ec63c http://hg.netbeans.org/web-main/rev/62248a869f8d http://hg.netbeans.org/web-main/rev/198a37bec7e6 http://hg.netbeans.org/web-main/rev/990edb3fe3ef http://hg.netbeans.org/web-main/rev/50a76e987933 http://hg.netbeans.org/web-main/rev/6895c6655524 http://hg.netbeans.org/web-main/rev/6e0b8a7e5db1 http://hg.netbeans.org/web-main/rev/c262321921e7 ..now it's working for J2SE projects and for all types of Maven projects. It's not complete for the Java Web project type, but I'm going to do that in a few days.
The following maven artifact combination works, but if I use maven-compiler-plugin 3.0, the tests are undetected: maven-compiler-plugin 2.3.2 groovy-eclipse-compiler 2.7.0-01 junit 4.11 groovy-all 2.1.1
Hi ronnie, could you please share simple project illustrating the problem so I'll be able to easily reproduce incorrect behavior? Thanks in advance
Created attachment 133307 [details] maven project that demonstrates skipping of tests when using maven-compiler-plugin 3.0 Test is run w/ maven-compiler-plugin 2.5.1 as well.
Looks like my issue was placing the groovy test scripts in the default groovy test package (src/test/groovy). If I place them in a package below the default package (e.g. src/test/groovy/mypackage), the tests are run during a mvn clean install.
Weird I'm able to test files even under the default package. For some reason I'm unable to unable to unpack your project, so I can't confirm it directly but I tried: 1. Create new Maven app 2. Update pom.xml to use versions you described in comment 15 3. Create new Groovy JUnit test in the default package 4. Run tests for the whole project ..as a result I can see two tests passed. Ronnie, is there anything else I need to do?
Would it be correct to assume that as of Netbeans 7.4 that all of the problems discussed here have been fixed? I suspect the answer is 'no' as I am seeing the same issues with Groovy testing in Netbeans 7.4. Or do we have to make the same workarounds for 7.4?
(In reply to cpscofield from comment #20) > Would it be correct to assume that as of Netbeans 7.4 that all of the > problems discussed here have been fixed? I suspect the answer is 'no' as I > am seeing the same issues with Groovy testing in Netbeans 7.4. Or do we have > to make the same workarounds for 7.4? Hi, could you at least describe what are you missing or what is not working for you? Comment complaining about everything is not really useful for anyone. Please, open another issue/issues with proper description of any kind of problem you are still facing and I will gladly take a look at it. Thanks for understanding.