Execute Groovy as JUnit test in Eclipse?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Execute Groovy as JUnit test in Eclipse?

KARR, DAVID
I noticed recently that the tests in the Gradle source code are Groovy scripts, but using JUnit.  I discovered that even though I set the root of the source tree as a source folder, the "Run As ..." options for one of those tests doesn't include "JUnit Test".  I must be missing something.

I'm on Kepler, with the latest released version of the Groovy plugin.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Execute Groovy as JUnit test in Eclipse?

Todd Bradley
I don't know Gradle, but are you sure the tests use JUnit directly and not Spock? Are you using an Eclipse distribution that has JUnit already installed? And is it included in the project's build settings?


On Fri, Jul 18, 2014 at 11:34 AM, KARR, DAVID <[hidden email]> wrote:
I noticed recently that the tests in the Gradle source code are Groovy scripts, but using JUnit.  I discovered that even though I set the root of the source tree as a source folder, the "Run As ..." options for one of those tests doesn't include "JUnit Test".  I must be missing something.

I'm on Kepler, with the latest released version of the Groovy plugin.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

RE: Execute Groovy as JUnit test in Eclipse?

KARR, DAVID

Yes, and yes.  It appears I didn’t have JUnit in the list of libraries, so I added that.

However, I’m now seeing bigger problems today.  It’s possible that the reason it didn’t give me the options I expected is because I didn’t have the project marked as a Groovy project. It was already a Gradle project.

 

Unfortunately, now that I’ve added the Groovy nature, it’s now complaining about very basic things.  I’m now getting compile errors on every source file, like the following:

------------------------

The declared package "org.gradle.integtests.samples" does not match the expected package ""

------------------------

 

I presently only have one source folder, which is “$projectName/subprojects/integ-test/src/integTest/groovy”, and rooted at that directory is “org/gradle/integtests/samples/<sourcefilename>”.

 

When I look in the Package Explorer, it lists this source folder, along with the various packages present in that tree, including “org.gradle.integtests.samples”.  Every single package and source file in this tree has a red X on it.  It seems a little mentally ill.

 

 

From: Todd Bradley [mailto:[hidden email]]
Sent: Friday, July 18, 2014 2:21 PM
To: [hidden email]
Subject: Re: [groovy-eclipse-plugin-user] Execute Groovy as JUnit test in Eclipse?

 

I don't know Gradle, but are you sure the tests use JUnit directly and not Spock? Are you using an Eclipse distribution that has JUnit already installed? And is it included in the project's build settings?

 

On Fri, Jul 18, 2014 at 11:34 AM, KARR, DAVID <[hidden email]> wrote:

I noticed recently that the tests in the Gradle source code are Groovy scripts, but using JUnit.  I discovered that even though I set the root of the source tree as a source folder, the "Run As ..." options for one of those tests doesn't include "JUnit Test".  I must be missing something.

I'm on Kepler, with the latest released version of the Groovy plugin.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

 

Reply | Threaded
Open this post in threaded view
|

Re: Execute Groovy as JUnit test in Eclipse?

Todd Bradley
My first guess is that you need to do a gradle refresh from inside Eclipse (I'm assuming you're using gradle from your earlier note). But that's just a guess. Gradle should be building your Eclipse project, with all the groovy and JUnit classpaths set up correctly.


On Fri, Jul 18, 2014 at 3:39 PM, KARR, DAVID <[hidden email]> wrote:

Yes, and yes.  It appears I didn’t have JUnit in the list of libraries, so I added that.

However, I’m now seeing bigger problems today.  It’s possible that the reason it didn’t give me the options I expected is because I didn’t have the project marked as a Groovy project. It was already a Gradle project.

 

Unfortunately, now that I’ve added the Groovy nature, it’s now complaining about very basic things.  I’m now getting compile errors on every source file, like the following:

------------------------

The declared package "org.gradle.integtests.samples" does not match the expected package ""

------------------------

 

I presently only have one source folder, which is “$projectName/subprojects/integ-test/src/integTest/groovy”, and rooted at that directory is “org/gradle/integtests/samples/<sourcefilename>”.

 

When I look in the Package Explorer, it lists this source folder, along with the various packages present in that tree, including “org.gradle.integtests.samples”.  Every single package and source file in this tree has a red X on it.  It seems a little mentally ill.

 

 

From: Todd Bradley [mailto:[hidden email]]
Sent: Friday, July 18, 2014 2:21 PM
To: [hidden email]
Subject: Re: [groovy-eclipse-plugin-user] Execute Groovy as JUnit test in Eclipse?

 

I don't know Gradle, but are you sure the tests use JUnit directly and not Spock? Are you using an Eclipse distribution that has JUnit already installed? And is it included in the project's build settings?

 

On Fri, Jul 18, 2014 at 11:34 AM, KARR, DAVID <[hidden email]> wrote:

I noticed recently that the tests in the Gradle source code are Groovy scripts, but using JUnit.  I discovered that even though I set the root of the source tree as a source folder, the "Run As ..." options for one of those tests doesn't include "JUnit Test".  I must be missing something.

I'm on Kepler, with the latest released version of the Groovy plugin.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

 


Reply | Threaded
Open this post in threaded view
|

RE: Execute Groovy as JUnit test in Eclipse?

KARR, DAVID

Hmm, that appeared to fix that, although it left me with an even stranger problem, affecting the Gradle part of this.

 

The project has a “subprojects” directory, with all the subprojects, obviously.  The “settings.gradle” file points there.

 

Before I did the Gradle refresh, I had several XML files from the “docs” subproject open.  When the refresh finished, the first file opened in the editor changed to say “subprojects/docs/src/docs/userguide/ideaPlugin.xml”.  All the other open files say the same thing.  In both the “Package Explorer” and “Project Explorer” when I look at the project, I see the “subprojects” folder, but it doesn’t have the little hollow arrow next to it, which indicates that it thinks the folder is empty.

 

At that point, I went into Project Properties.  I used to have one source folder that I added manually, so the unit tests would be in a source folder.  When I went back in now, there were no source folders.  I tried to add back the one I had, but when I navigated to the project, it showed the “subprojects” folder, but it was empty.

 

I then went to the shell, and explored the project.  There appeared to be nothing wrong with the “subprojects” folder, it appeared to have all the files it had before I did the Gradle refresh.

 

I suppose this is just a Gradle plugin problem, although I suppose there could be an interaction problem with the Groovy plugin.  I’ll describe these symptoms on the Gradle forum.

 

From: Todd Bradley [mailto:[hidden email]]
Sent: Saturday, July 19, 2014 6:27 AM
To: [hidden email]
Subject: Re: [groovy-eclipse-plugin-user] Execute Groovy as JUnit test in Eclipse?

 

My first guess is that you need to do a gradle refresh from inside Eclipse (I'm assuming you're using gradle from your earlier note). But that's just a guess. Gradle should be building your Eclipse project, with all the groovy and JUnit classpaths set up correctly.

 

On Fri, Jul 18, 2014 at 3:39 PM, KARR, DAVID <[hidden email]> wrote:

Yes, and yes.  It appears I didn’t have JUnit in the list of libraries, so I added that.

However, I’m now seeing bigger problems today.  It’s possible that the reason it didn’t give me the options I expected is because I didn’t have the project marked as a Groovy project. It was already a Gradle project.

 

Unfortunately, now that I’ve added the Groovy nature, it’s now complaining about very basic things.  I’m now getting compile errors on every source file, like the following:

------------------------

The declared package "org.gradle.integtests.samples" does not match the expected package ""

------------------------

 

I presently only have one source folder, which is “$projectName/subprojects/integ-test/src/integTest/groovy”, and rooted at that directory is “org/gradle/integtests/samples/<sourcefilename>”.

 

When I look in the Package Explorer, it lists this source folder, along with the various packages present in that tree, including “org.gradle.integtests.samples”.  Every single package and source file in this tree has a red X on it.  It seems a little mentally ill.

 

 

From: Todd Bradley [mailto:[hidden email]]
Sent: Friday, July 18, 2014 2:21 PM
To: [hidden email]
Subject: Re: [groovy-eclipse-plugin-user] Execute Groovy as JUnit test in Eclipse?

 

I don't know Gradle, but are you sure the tests use JUnit directly and not Spock? Are you using an Eclipse distribution that has JUnit already installed? And is it included in the project's build settings?

 

On Fri, Jul 18, 2014 at 11:34 AM, KARR, DAVID <[hidden email]> wrote:

I noticed recently that the tests in the Gradle source code are Groovy scripts, but using JUnit.  I discovered that even though I set the root of the source tree as a source folder, the "Run As ..." options for one of those tests doesn't include "JUnit Test".  I must be missing something.

I'm on Kepler, with the latest released version of the Groovy plugin.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email