How to run SWTBOT in eclipse juno - java

I am not finding any clear documents to start the Swtbot. I am trying couple of days to start it.
Can any one please help me configuring and executing the swtbot?

If you are just starting with SWTBot, it's good to start with running it on Eclipse IDE(assuming you're using Eclipse).
Install SWTBot in Eclipse from update site http://download.eclipse.org/technology/swtbot/releases/latest/.
Now go to Run Configurations and find a section named SWTBot Test on left side.
Right click and create a new SWTBot launch file.
In the Main tab you can configure which class or suite or test method to execute.
You can also configure which product you want to run your tests on.
It'd be more helpful to answer if you provided with how far you have gone.

If you're in IDE (with SWTBot installed in it), just right-click on your Test Case and select "Run As > SWTBot Test Case". This will create a good enough launch configuration (that you can refine later if necessary).
If you're trying to run tests independently of the IDE, please read https://wiki.eclipse.org/SWTBot/Automate_test_execution

Related

Continuous testing with IntelliJ Idea

I'm looking for an IntelliJ IDEA plugin that would run my tests each time I change my code. I looked for such a solution and I found:
Infinitest, which works, but is inconvenient because I need to add the facet to each module, and it opens a new tool window for each module (which means 15 tool windows for me).
Fireworks - didn't work for me, maybe it just doesn't work with IDEA 14 (in its repo I can see that last changes were made in 2009). IntelliJ also reports that it throws exceptions.
There are lots of ways I could run all my tests (including writing a simple script for this), but I'm looking for a tool that would be smart enough to rerun failed tests first, and that would understand module dependencies (so after a change in some module it would run only tests of dependent modules).
I prefer free options, but if there's something paid for a reasonable price, I would accept it as well.
IntelliJ now actually has a Toggle auto-testin the run dialog. Just run a run-configuration and then select Toggle auto-testin the run dialog.
It's not as intelligent as you would have hoped. It just reruns when it detects changes.
I know this is a 3-year-old question but I think it will help people who face the similar problem in future. So I found out a way to enable SBT style auto test execution in IntelliJ studio.
We need to do 2 things to enable auto test execution.
Enabling auto project build - This can be done in settings by going into File -> Settings -> Build, Execution... -> Compiler and selecting "Build Project automatically".
Enabling "Toggle auto-test" in run dialog box
This will start auto testing. Although this works fine, it takes time to build the project even when my project is tiny so for larger projects it will certainly take very long time to complete the build and execute tests.
Reference: Original article which explains these steps
If you are OK running tests which cover a single method chosen by you, you can try this plugin (it is continuos in the sense that you make changes to a method, then click on the method and the plugin will run all the unit tests automatically which cover that method): https://plugins.jetbrains.com/plugin/15063-unit-test-coverage-history-runner
You can use the Intellij Teamcity plugin. Teamcity is a paid product but there is a free version which gives you 20 projects and 3 agents for free .
It has a remote run feature using which you can send in unchecked code to run tests before committing.
It also has options to run failed tests first
Usage instructions for Remote Run

How to recognize a shell on the desktop for testing using swtbot?

I have an application that generates an SWT UI (with a text entry field and two buttons, similar to eclipse workspace selector). I want to generate test cases for this using SWT bot. I get the application to run using java (by executing the double click event). Then my application will generate the UI of and I want to recognize this UI from SWT bot test class. How can I recognize this when the UI is up?
I have written a unit test by invoking the method that creates the UI separately, but this is an integration test in which i need to test the whole flow of the application similar to user experience.
thanks in advance
I hope you installed SWTBot ide integration from an update site like http://download.eclipse.org/technology/swtbot/releases/latest/
If you want to run the SWTBot testcase from Eclipse do following:
Open Run->Run Configurations
Find SWTBot Test node on left of the configurations dialog
Create new configuration with right click on the node.
Select your test class/method/package/folder on Test tab, choose JUnit 4
Select your application/product on Main tab.
Select the dependencies you application requires on Plugins tab. There you
go Run :)
It is highly probable you'll fail at first attempt.
In that case on Plugins tab click on "Validate Plug-ins" and make sure you get the message "No problems were detected" or something like that.

Eclipse run as junit test missing

I am trying to run a test case but when I right click on the test class, there is no option for run as junit. I know there are similar questions, I tried them but did not work for me. The only thing is that in one question they suggested to take a look at
Window > preferences > java and see if there is any junit. For me there is not but I do not know how to resolve it.I have installed it. I added it to the plugins and also in my build path but still it does not show up.

Can you force eclipse to run/debug another project when a particular one is ran/debugged?

I'm working with Ligdx, an API for cross plattaform game development that by default generates at least 2 projects:
The core project: This is the one you are supposed to work on, where all the classes and logic should be placed.
The desktop project: This one is automatically generated from the core project.
The core doesn't have any class to start it because it's supposed to be started from the desktop (or other platforms) project.
It is also always selected -because its what you are working on- so pressing the "run" or "debug" buttons will attempt to run the core project and not the desktop one and immediately fail thus forcing you to select the desktop project before hitting run/debug. This can get extremely annoying, especially when debugging.
So is there a way to force Eclipse to always run the desktop project?
Rekaszeru's answer to this question shows how to set up Eclipse in order to always launch the previously launched application.
You simply have to go to preferences / run-debug / launching and check the "Always launch previously launched application" box as he shown in the picture he used to illustrate his answer:
This will not force one of the projects to always be launched but it would pretty much solve the problem unless you are working on multiple projects at the same time or you alternate between Web/Android/Desktop.
If Your asking how to start a Core project from already existing project present in the eclipse then all you need to do is Right Click on desktop folder of the project and go over Run As and select Java Application
But if that is not what you have posted for I can only understand that you need to understand how a LibGDX project is deployed.... From Desktop project "In xyzMain.java" file you will have a method call to the core project saying:
new LwjglApplication(new Sample(), cfg);
This is where you'r Sample Class from the core project is called over.
But from the title I get a diff feeling that you wish to add another project to your already existing project...
You can do that by changing the build Path of the project....by including Other proj to the one you wish to compile and run.
Hope this helped you out..
I´m not aware of doing exactly what you have described, but I´d suggest using the Launch Configurations menus and dialgos to do what you want in a similar quick way.
Note that you can configure your launch configurations doing: Run -> Run Configurations... (also Run -> Debug configurations...)
Option 1).
Once you have run your Desktop Project, simply use the Run Drop-down button, which contain your launch configurations:
Option 2).
Save a launch configuration file in your Core project (or wherever you want) using the last "common" tab of the launch configuration dialog:
Then you can simply right-click on your that file to launch your Desktop Project:
P.S: I´d also suggest reading a little bit about run configurations in lars tutorial

How do I run JUnit from NetBeans?

I've been trying to understand how to start writing and running JUnit tests.
When I'm reading this article:
http://junit.sourceforge.net/doc/testinfected/testing.htm
I get the the middle of the page and they write, "JUnit comes with a graphical interface to run tests. Type the name of your test class in the field at the top of the window. Press the Run button."
I don't know how to launch this program. I don't even know which package it is in, or how you run a library class from an IDE.
Being stuck, I tried this NetBeans tutorial:
http://www.netbeans.org/kb/docs/java/junit-intro.html
It seemed to be going OK, but then I noticed that the menu options for this tutorial for testing a Java Class Library are different from those for a regular Java application, or for a Java Web App. So the instructions in this tutorial don't apply generally.
I'm using NetBeans 6.7, and I've imported JUnit 4.5 into the libraries folder. What would be the normal way to run JUnit, after having written the tests?
The JUnit FAQ describes the process from the Console, and I'm willing to do that if that is what is typical, but given all that I can do inside netbeans, it seems hard to believe that there isn't an easier way.
Thanks much.
EDIT: If I right-click on the project and select "Test" the output is:
init:
deps-jar:
compile:
compile-test:
test-report:
test:
BUILD SUCCESSFUL (total time: 0 seconds)
This doesn't strike me as the desired output of a test, especially since this doesn't change whether the test condition is true or not.
Any ideas?
One way is to right click on your project in the Projects pane and select "Tests". That will run the JUnit tests. You can also right click on the test file and select "Run Test" and that single file will be ran. The keyboard shortcuts depends on how you have your keymapping set, but you'll see them in the context menus.
You can also have NetBeans autogenerate tests for you by right clicking your source file and then "Tools > Create JUnit Tests".
Re-importing does not appear to be necessary. I had the same issue (imported project, right clicking did not bring up any JUnit test options). I took these steps, which resolved it, using NetBeans 6.8:
Add a folder called "tests" to your project.
Right-click your project and select Properties.
Select Sources.
Under Test Package Folders, click the Add Folder button, and select the "tests" folder.
Right clicking a file + Tools > Create JUnit Tests.
Once a test is created, right-clicking a file + Test File runs the test.
All the above answers are correct, but if you are using in mac little change needed.
Step 1 Write your junit class.
Step 2 Right click on the class ->Tools-> Create/Updates Tests-> Select framework as Junit-> click ok.
Step 3 Right click on the file again ->Test File.
Now it will run as junit, will show the Test Result.
Even though I've accepted an answer, I thought I should mention my difficulty, as someone else may encounter it.
When importing a project from existing sources into NetBeans, if you do not specify a folder for test packages, then NetBeans will not offer the JUnit options on the tools menu.
The only solution I found was to re-import the project. While primitive, it worked.
I had the same issue after imported a eclipse project into NetBeans.
To resolve it, I followed the above steps outlined by alangalloway, but instead of
creating a new folder, I just pointed to the imported test folder.
Maybe in future release, NetBeans can automatically recognize imported test cases.
Thanks.
Had a similar issue. In Netbeans 7.0.1, what worked for me was to locate the project.xml file (i.e. {project}/nbproject/project.xml) and change:
<test-roots/>
to:
<test-roots>
<root id="src.dir"/>
</test-roots>
(in my case the test files are in the same dir as the source dir)

Categories

Resources