Eclipse run test one by one - eclipse

I'm looking for a way to run a only a one test case in my test class from the some kind of test methods list.
For example, when I run a whole batch of test methods, the failure list appears like that:
And I can right-click on the appropriate test method and re-run it without a running a whole batch. But in the next i'm getting the error list, that consists of only that method:
At that point it would be nice to run the another test method as only one, without running a whole batch. Is there a way in Eclipse to get the list of my test methods where it's would be possible to choose the method to run?

In the JUnit view toolbar there is a Test Run History... button/drop-down where you can go back to the test result of a previous run without rerunning it.
In addition, you can also right-click on a test method to run this method only: for example in the Java editor, in Outline view of the Java editor, in the Package Explorer or in the Project Explorer.

Related

How to run specific tests from one class xcode uitesting

I'm creating ui tests in xcode using XCTest(Swift)
How can I run, for example, 2-3 tests from one class without launching the rest of the test from this class?
Is it possible to add some tests to suite or run and run from command line just necessary suite/run?
According to the XCTestSuite documentation there is an option to create a custom test suite, but I haven't found any examples of it.
You can adjust which tests you want to run in the scheme, under the Test menu. There will be a list of your test classes and tests in a disclosure triangle hierarchy in the Edit Scheme > Test window, where you can select or deselect tests. When you run the tests with that scheme selected, only the tests you selected will run.
You can use multiple -test-only params in your run
xcodebuild test [...] -only-testing:"superApp/SuperTestClass/test2" -only-testing:"superApp/SuperTestClass/test5"

During debug scala in intellj, can we pause on a statement, and then run other code?

Sometimes I need interactive with scala console during debug. What I am doing now is: write a class with a method, and let that method return some object, then in scala console, I import that class ,create a new instance and run the method to get a object, then doing interactive thing with that object. If I need to modify that method, then I have to first change in IDE, then exit console, re-run console and import the class (since the class is change), to run the method again. This takes time, if it possible in IDE, set a breakpoint, run until that breakpoint, and then kick off a console, and doing interactive thing in that console?
The way I work within intellij is to use the terminal console, and have that in the lower third of my IDE window, and then have SBT (console) or scala just running in there. That way you can just switch between windows and evaluate expressions you need to from there. If you want to evaluate specific (in place) expressions such as those that are only in context within the currently debugged block of code, then I think that you might be able to do that via the Watch window. There is an option in Intellij 14 which pops up a separate evaluation window. (Not tried this with Scala though to be honest, but works well with Java).

Eclipse IDE debugging with code change

I am using Eclipse IDE for Java Developers
Version: Helios Service Release 1
Build id: 20100917-0705
In remote debugging Web app with tomcat 7.0.37, when I make some changes, even a line, the changes can not be made into the runtime, so I need to recompile and re-deploy the war application. Wast a lot of time. The message:
Hot code replace failed - Delete method not implemented
I do not understand the message.
Anyone know the secret on how to auto reflect the code change in debug mode? Thanks.
I've found that for hot code replacement to work the code being modified/replaced must be in the execution stack. So you can hot replace changes made to a method you've stopped in, but you can't hot replace changes to that method once you step out of that method... unless you first stop back in the method on a successive call to the method.
With the standard JVM (Oracle's), you can only modify existing methods. Both adding and deleting methods, and changing structure of class (moving methods, fields) are NOT supported. For that, go to JRebel!
One thing to notice is that changes to seemingly "normal code" inside some method will actually need for the java compiler to add or delete methods - and hence it will fail. This happens e.g. if you in an inner class accesses private fields in the outer class - the java compiler will need to add synthetic accessor-methods to the outer class to let the inner class access those fields - which hence will fail to Hot Code Replace. Also, if you remove some code accessing such fields, the java compiler wants to remove the corresponding synthetic accessor-method, which also will fail.
I think there is no way to reflect the code change in debug mode
Debug mode is to trace program flow and find if any issues or errors at particular piece of code....
it just points to line of code in eclipse, which is running in your tomcat, ie. code in eclipse is not used to run application the code u have installed or put in tomcat runs
hence your changes made in eclipse cant reflect in tomcat code

PerlUnit in Eclipse

If we click on Java perspective in Eclipse and right click on a Java project, we see “new” a JUnit file.On executing the test cases in JUnit we see red/green bar displaying failure/success of test cases.
I am trying to find a plugin that would add these two features :
In the perl perspective (provided by EPIC) , right-click on a Perl
project should list a new “t” file.
On executing perl unit the status of test cases should be displayed
using Reed/Green bar.
If there is no plugin is there a way we can do the same.
As far as I know, there is no EPIC plugin for this or even a more generic TAP-based test runner for Eclipse. Such a thing would be nice to have.
Rigging some sort of report on test success from a web page is pretty common. This can be done using a tool like Test::Harness which can be used to run your test or tests and return or output a report of how well your test run went.
From there, it's a matter of turning that into a red/green progress bar.
If you want to see the progress updated continuously during the test run, you'll have to run and parse the test files more directly as they run. All Perl tests output TAP format, which is a standard format with specs available here:
http://testanything.org

Running a single JUnit test in Eclipse

If I have a test suite with multiple tests, when I try to run a single unit test, either from the context menu of the code editor, or from the JUnit view, it seems to insist on always running the entire suite, rather than the single test. Is there a way to disable to change this behavior so that I can ask to to run that, and only that, test.
In the package explorer unfold the class. It should show you all methods. Right click on the one method you want to run, then select Run As -> JUnit from the context menu (just tested with Eclipse 3.4.1). Also selecting "Run" on a single entry in the JUnit-results view to re-run a test works in the same way.
Fastest way I know of:
Press Ctrl+Shift+↑ (moves cursor to current method declaration),
press Alt+Shift+x (or d for debug) then press t (hotkey for "Run JUnit Test"),
check test result,
press Alt+← to get back to the line of code you were before.
If you want to run all tests, you can skip steps 1 & 4.
In Eclipse 3.5, you can get around this by changing the test runner to JUnit 3. This will only work for JUnit 3 tests, not JUnit 4 tests. You can change the test runner by doing the following:
Right click on one of the test methods in the Outline explorer
Select Run As -> Run Configurations
On the 'Test' tab, select 'Run a single test'
In the Test Runner dropdown, select 'JUnit 3'
It may work in other versions as well.
This is possible in Eclipse Indigo with JUnit 4.8.2. You right click the method you want to unit test individually in the Outline pane, and select Run As -> JUnit Test.
You can even selectively right click a Test method name in the source editor and select Run As -> Junit Test.
Don't use Strg+F11 but the hotkey Alt+Shift+X -> T.
Then Eclipse will execute the current open file as a JUnit test. The green play button will only run the last chosen Run Configuration.
For me, it works well with Alt+Shift+X -> T.
I'll add to the others by including a highly productive keyboard only way that allows you to debug a single unit test (method).
Move your cursor to the method name by using either
Ctrl+Shift+Up or
Ctrl+Shift+Down or
Ctrl+o then type the name of the method
Once your cursor is on the method name (or right before it):
Alt+Shift+D -> T (Debug)
Alt+Shift+X -> T (Run)
After you run the test you can go back to where your cursor was by doing:
Alt+Back
You almost get REPL like behavior by:
Ctrl+Shift+Up and Alt+Shift+X -> T and Alt+Back
You can also quickly set a breakpoint:
Ctrl+Shift+B
Right click somewhere on the test method name in the file and select "Run" -> "Junit Test". I do it all the time with Kepler and JUnit 4.
To run only one test method.
In the (package explorer or project explorer) unfold the class. It should show you all methods. Right click on the one method you want to run, then select Run As -> JUnit from the context menu.
I had the same problem others have had using Eclipse 3.4.1 and JUnit 4 test runner -- couldn't run single test. But I found a suggestion somewhere else that resolved the problem. My test class was still extending junit.framework.TestCase. When I stopped extending TestCase, everything worked fine and I was able to run single JUnit tests with the JUnit 4 test runner. Of course, I needed to JUnit 4 annotations use static imports for the assert methods, but I had already done that -- I had just not removed the TestCase inheritance.
If you have many tests in more than one file, and you want to run only the tests in a particular file, you could right click that file, and select run as -> junit test.
Now, if you want to run only one test, contained in a file with many tests, my guess is (I dont have eclipse installed here) that the Outline view will list all test methods for a file, and you will probably be able to right click a single test method and execute it as a JUNit test.
Hope it helps.
For me, it also does not work in Eclipse 3.4.2 , although it worked in the previous releases (I have tried running single method from package explorer and single junit test from junit view)
I agree with the point about 3.4.2 no longer working the way it did in previous versions. Before you could right-click on a single test in a group of tests from the JUnit view and execute just that test. In the latest version it insists on always running all of them. Granted, the view does run the test you clicked on first and dumps the rest in a rollup called "Unrooted Tests". If anyone figures this out I'd like to know how to get around it.
Reading some of the comments here, it seems you might be interested in running the tests for the code you change as you change it, without losing focus on the code you are working on. There's an eclipse plugin for doing just that. See infinitest.
If by test you might even mean single test method I like to use "Run Tests of Selected Member" using a key binding.
When I am inside of a test method only that test method will be run – if I have the cursor in the class scope it will run the whole class. I changed the default binding to something easy like Ctrl+r since I use it a lot.
Please see:
(If you don't see that keys entry it might come from the MoreUnit plugin – which is great anyway and you might want to have it)