Junit can´t run test class in Eclipse - java

I want to run the class "SimpleTests" but in the dropdown menu of the run icon, it doesn't show any option to run this class. There are only my other test classes for different projects available.

Related

Eclipse - Set Execution preference between Java Application and TestNG

I have a TestNG class file.
Whenever I try to execute it, I get the "Run As" options to select between Java Application and TestNG Test.
How do I default it to take always TestNG for this class file, whenever I execute it? Is there any association for class files to the way it has to run?
I've tried Window->Preferences->Run/Debug and in the Launch Operation -Setting it to option --> Always launch the previously launched application.
But, that doesn't solve my problem as that executes the previous launched application always even if I open another class file with a main to it.

Selenium Java - how do I run only one test?

I am currently using Java and Selenium and I have over 50 tests in just one class. Is there an easier way to run only one test, other than putting #Ignore on every other test?
If you are using Eclipse you can do following:
go to your class file (source code)
right click on your testing method name
click "Run As.."
click "Run Junit Test"
it will run the one that you want to test

How to determine the main class in a java application?

When I load a sample application in netbeans (anagrams that comes with it) and I hit run, the program just runs .. how can it determines the entry point for the program (class which has main method) ...
All classes that can be run have a small green triangle on their icon in the "projects" view.
If a default class is set to run with the project, you can see it by right-clicking the project and selecting "properties". Then in the project properties, go to "Run" and you should be able to see the main class.

How do I set the main Java type in Eclipse?

How do I set the main Java type in Eclipse (latest)?
I have a main client, and then a bunch of unit tests that exercise various code paths and conditions. Normally I'd like to debug or execute the unit tests depending on the feature I'm developing. However, when the boss shows up, I'd like to quickly run my main driver class without hunting and pecking for the .java file, then hitting debug.
Is there an easy way to set/change the main type? How do folks normally handle running unit tests in Eclipse?
Click on the arrow in the run/debug icon and select Organize Favorites at the bottom and set favorites for anything you don't want to fumble around for later.
For unit tests, I just run them like anything else in Eclipse. I also include a test target in my Ant scripts.
For unit tests :
You can make test suite so to bundle them by feature. This way you just need to run the test suite related to your feature.
Having several launch configuration :
Just go Run Configuration... or Debug Configuration ... from Run menu and create the configuration you want. Next time you'll want to Run them go again to that menu select it and click Run/Debug;
To gain time you can go to Keys configuration and set at shortcut to "Run..." or "Debug..." submenu.
Right click on your test folder and "Run as ... -> JUnit test"?
From Run > Run Configuration... Create a new Run Configuration for the type of java application you have and the options let you specify the main class.
And these configurations will be available in the Run As button dropdown.

TestNG: Eclipse confused by JUnit

I'm setting up tests with TestNG in an Eclipse project, but I get a strange error: When I try to generate a test class from a business class, I get a popup with a message saying "Grid not editable" (title) "The compilation unit is not compilable, or is not a sublcass of junit.framework.TestCase. Fix and tyr again" (body).
Somehow, Eclipse seems to think I want to create JUnit classes, and I can't get why. Any clue?
Configuration:
Eclipse 3.6.0
TestNG 5.14.10
Google CodePro Analytix, the newly open-sourced static analysis tool, is the cause of the problem. It creates a new default editor filter which tries to open each class which name ends with "Test" with its specific JUnit editor. The TestNG plugin for Eclipse, on the other side, generates test classes using the tested class name, with "Test" added at the end. So when you create a test class with the TestNG plugin, it's opened by default with CodePro Junit editor, which dispays an error popup saying the class is not a valid JUnit test class.
Solution is to remove the editor filter in Eclipse Preferences:
Window -> Preferences ; General -> Editors -> File Associations
Select the *.java file type, pick Java Editor and click on the "Default" button.

Categories