In Eclipse, it is very easy to run Java classes and Junit tests with a click, Eclipse does all the hard work of figuring out the class path.
But if I want to create an Ant task that will run a specific Java class or Junit test - I have to figure it out myself.
Is there a way to tell Eclipse to automatically create an ant build file for these tasks?
Related
I'd like to execute my Clojure tests directly from eclipse (alternative would be to run lein test from the commandline).
I already installed the CounterClockwise-Plugin for Eclipse, but there is no "Run as / Clojure test" in the context-menu. So far I added a (run-tests) to the end of my Clojure-tests files and execute the test via "Run as / Clojure Application".
Is there a better way to run tests from eclipse? In general it shouldn’t be necessary to add code to start the tests.
You can open a project REPL in Eclipse, move the REPL to the test namespace and (run-tests) from there.
I have an existing Java project set up in Intellij 12 and am attempting to add some Groovy classes to it. I've started with attempting to add a simple Spock class for testing purposes, but when I right-click on the class it does not give me an option to run it.
I've taken a look at my Intellij configuration and it pulls in groovy correctly. Further, I can write a Groovy script that uses a Groovy class and that runs without problems so it appears that Groovy is wired in. Is there something else I need to configure to specifically run Spock tests?
Easiest way to get spock and all dependencies is add library from maven.
Then, you should place your test in a folder, marked as test folder, if you want to allow batch processing of them.
If you place your script in folder, not marked as test, or source folder, you will be unable to run it.
If you can't see run button, it looks like Idea cannot recognise file as runnable, it isn't under source/test root, or it's extension is invalid.
You can add Spock plugin by:
Downloading the jar
In IDEA File->Settings->Plugins->Install from disk. Choose the jar.
I was having the same issue and ended up here. I found that I had forgotten to extend spock.lang.Specification. As soon as I did, the Run option showed up.
Just posting in case it helps any other Spock novices like myself.
I have an eclipse application, where in i can create projects and perform some operations. I have written a test cases using Junit for some functions. To run these test functions, i am doing Right click on test class and Run as Junit Plug-in test and it is working properly. I am unable to do both the things at the same time. What i need is to run my eclipse application and Junit plug-in test simultaneously without human intervention. Junit plug-in test has to be done at run time. If there is a way to do that, then please suggest me the solution.
When you run it as Junit plugin test, then it already launches your eclipse plugins (and application), so there is absolutely no need to try to launch an additional application.
What probably confuses you, is that the test run and the "normal" manual run use two different workspaces. So if you try to access some files in your test which you created during normal operation, they will not exist. But you should never rely on such things, instead you have to create the necessary artifacts in the test setup method.
I wrote an ant task to run my project in NetBeans (I'm using a freeform java project). Now I want to write a debug task. The debug task is nearly identical to the run task except for a few added properties. Can I subclass the run task and add in the extra properties?
Since an Ant task implementation is a Java class, Ant tasks may be subclassed just like any other Java class. However, the usual method for testing tasks is to write both JUnit and AntUnit tests.
For examples, take a look at the Apache Ant source code under tests.
and the second question:
is it possible to run them all in a bunch through Eclipse?
One approach could be, Install 'antify' module and run 'play antify' on your application. It will create a build.xml for your app (which would import the needed targets from application-build.xml file) and run 'auto-test' from eclipse.
FunctionalTest and UnitTest extend BaseTest, which is annotated with the PlayJunit4TestRunner, so you should find that you can just run tests as you would with any other test (i.e. Run As > Junit Test). You'll see the Play environment being initialised on the console before the tests actually run.
One problem I've found is that running a whole package of Play tests in Eclipse is buggy, so I tend to just run one at a time in Eclipse and then use Play's own testrunner to verify the whole suite.