I practice TDD and run my tests very often. Eclipse has a nice command to run the last-launched configuration. But when I invoke the command in some unit test class, Eclipse runs only the tests for current unit test class. I want run all my unit tests instead.
Yes, I can use the mouse to invoke the command that runs all JUnit tests, but, to repeat: I run tests very often.
You need to change eclipse's run mode. By default, it will try to run whatever is selected or being edited. You want to it always run the "last thing executed".
Go to Window->Preferences->Run/Debug->Launching
Choose "Always Launch the Previous Application"
Then you can define a TestSuite with all of your test cases and run it, or run all test cases for the project. Once run, you can just keep re-running with F11 or control-F11.
Hope this helps!
-- Scott
Maybe Infinitest is what you need.
You can create a JUnit launch configuration for all of your tests by right clicking the tests folder and choosing "Run As > JUnit Test".
Then see https://stackoverflow.com/a/8176077/255961 which describes how to use the Practically Macro plugin to assign shortcuts to launch configurations.
PS, If for some reason you have tests in more than one folder you can then edit the JUnit launch configuration to work at the project level as well:
To run all unit tests in a project, package or source root, select the item in the package explorer and hit Shift+Alt+X then T (or right click->Run As-> JUnit test).
To get the focus on the package explorer, hit Ctrl+F7 to bring up the "Next View" menu, hit it repeatedly to cycle through the list or hit up and down arrow then enter to select the view.
Once you've run it once, F11 can be set to run the last launched if you tweak the debug preferences (the default is to run for the current selection).
There is also Junit Max. It is not free but very cheap. It will run all your tests every time you save a file and indicate if the tests were successful in the right bottom corner of eclipse.
If a tests fails the line where it fails is marked as an error so you can keep working with the source files and don't have to wait for your tests and have your workflow interrupted.
Related
What I do:
Set up fresh Cucumber maven project using "cucumber-archetype" from io.cucumber in Eclipse 2022-09
Set break points in StepDefinition java source
Run "Debug as Cucumber Feature" on feature file open in editor**
Stepfilters disabled to make sure I'm not filtering anything out
What happens:
"Step into" moves ahead as with normal debugging, but does not go into any source to show line by line which java code is executing.
Expected:
"Step into" to go into source files to show line by line which code is executing, just as happens doing any other debugging with junit5 tests.
What I have tried:
Converting to Cucumber nature
Did maven update project
Project content
A test project contains these test scope dependencies, beyond imports cucumber-bom and junit-bom:
cucumber-java 7
cucumber-junit-platform-engine 7
junit-platform-suite 1.9.1
junit-jupiter 5.9.1
…so nothing more complicated than a base project is needed to get this behavior.
My questions:
Are my expectations of step debugging here unreasonable?
Have I perhaps missed some vital set up step for a cucumber project in Eclipse? Please note I have basically described above what set up I've done as this is an archetype.
If not, how could I set it up to allow stepping into code also when running a Cucumber feature file in debug mode?
** This is the only way to execute the feature file in Eclipse that I know of.
Here's one solution: Run the Cucumber runner java source file as a JUnit test in debug mode, instead of the feature file directly:
Right click on the Cucumber runner java source file
Select "Debug as" > "Junit Test" in the popup menu
This method both gets the input data as well as evaluation results from the Cucumber feature file and renders test results in the JUnit view as well (albeit not 100% useful). Most importantly code stepping into source now works as expected.
I've just started using MoreUnit and it seems quite handy. One thing that I am missing however is how to run tests using the debugger right away rather than just plain Run (using ^R).
It's not in the context menu and I have tried a few keyboard shortcut variations to no avail...
Usually in Eclipse, you can just click on the debug button after running the tests normally to debug them (the last run will have created a launch configuration that you can also access from the debug menus).
Other than that, you should find a "Run as MoreUnit test..." in both the "Run" and "Debug" menus (if not, file a feature request).
Lastly, you should be able to open the "Launch Configuration" wizard by selecting "Debug..." and there should be a folder for MoreUnit in the tree on the left. Above the tree is a "+" option to create entries in a folder.
Thanks to those info http://www.ralfebert.de/blog/wicket/wicket_eclipse_setup/ and How can I begin using Wicket? now I am able to edit Java code and html files with Eclipse, and run it to get Jetty started.
However there are still two problems which do not allow me to repeatedly run the project:
I have to stop previous run in order to run it again
unlike regular Java project, where I could simply choose "run", now I have to go into "Run Configuration", select Maven Build type, and below select my project to run, and then finally click "run"
ad.1. How to make Eclipse stop the previous run on next run -- i.e. I would like to just run project, and Eclipse should either run it, or stop previous one and run it again
ad.2. how to "bind" Run/Run to running my configuration (Maven Build / my project)?
Thank you in advance for help.
Another simply option is to use a Start class with a main that runs and embedded jetty. Then you will be able to run and debug your application as a normal desktop java application with your IDE.
Check the example start file that comes with the wicket quickstart here:
https://github.com/jordeu/wicket/blob/master/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java
I can run all tests for current file, but how to run only one test?
There are buttons in the Test Results pane to rerun only the tests that failed during the previous run, but I know of no way to run a single test. Right-click a test in that same pane to see if you get an option to run it alone. I'm not at work to test out that theory.
There is a way to do it netbeans: Click Window -> Ide Tools -> Terminal and type:
phpunit --filter '/::testName$/' MyTest.php
Then click Enter.
as far as I know there is no button or something in Netbeans that does that. So using terminal seems like the easiest way. It still is quite convenient though, because it should remember the history and later on you can just copy paste the test name.
Note that you may have to navigate to the test folder first or specify path to your Test file first in case Netbeans terminal doesn't open in your test project folder already
I have a set of dependent projects in Eclipse, each with its own Ant build script. If I make a change in multiple projects, then select "Build All" (Ctrl+B), each Ant build is invoked in the correct order. But if there is an error in one project, Eclipse still tries to build the other projects also, and in the process clobbers the Ant console so that the build errors are no longer visible. This wouldn't be quite so annoying if I could open up the offending project and select "Build Project", but Eclipse out-smarts me: it won't rebuild until I open some file in the project, edit it, and save (typically I add and remove a space character wherever my cursor happens to be). An answer to any of the following questions would be welcome.
How can I configure Eclipse to (in preference order):
terminate a "Build All" as soon as any project's Ant build fails?
save all console output for "Build All" instead of resetting the console for each project?
spawn a separate console for each new instance of Ant?
allow me to force a "Build Project" even if it doesn't think anything has changed?
[UPDATE] Bonus Question:
How can I configure Eclipse so that fixing any build errors in a depended-on project counts as a "change" for the purposes of "Build Project"?
Have you tried redirecting standard out to file via a run configuration? A few screen shots to help if not... (you may try 'append' this is not in my screen shot :) )
One alternative is to have each Ant build log itself, e.g., using the following in build.xml
<record name="build.log"
loglevel="verbose"
append="false" />
Oddly, Eclipse seems to disable this logging somehow when running an Ant build.
I am not too big on ant, but can't you make the builds dependent on one another?