JUnit Could not launch the JUnit plug-in tests. why? - java

First time I am trying Junit and I am following below link:
http://www.vogella.de/articles/JUnit/article.html
When I run my testClass as Run-As-> Junit Test. It says below thing.
Please help me in figure it out.
Could not launch the JUnit plug-in tests because project 'SalesTax'
is not a plug-in project.
SalesTax: Is the Project Name

I suspect you did create an Eclipse 'jUnit Plugin Test' launch configuration which is designed to run Eclipse plugins jUnit tests (in some kind of mocked eclipse environment).
Try to create a simple 'jUnit' launch configuration instead.

Suggestion - Follow the tutorial. type in the (3-line) example "MyClassTest" from the tutorial. Verify that you can get the tutorial working. Post back with any questions about the tutorial.
Once you get one complete example working, end-to-end (your code, your JUnit test code, and successfully building and executing at least one JUnit test in your IDE), then try to get your "SalesTax" project working.
Q: I presume you're using Eclipse, correct? Eclipse 3.7?
PS:
Here's another good tutorial:
http://www.ibm.com/developerworks/java/tutorials/j-junit4/

Related

Test Runner tab in IntelliJ 2018.3 CE not showing

I'm using IntelliJ 2018.3 CE. I have a java maven project (developed using springboot) in which the JUnit tests have already been written. However, when I try to run the tests, the output is always shown in the default run window, and NOT in the Test Runner Tab. In fact, I cannot make this window pop-up after a running a test.
I have Junit 4.12 in the external libraries of my project (as Maven: junit:junit:4.12). The test folders have been appropriately flagged as test resources.
I presume it has to deal with settings in IntelliJ but even with all the effort in the world, I wasn't able to find what is causing this.
Is someone experiencing the same issue? Or does someone know how to resolve this?
Any help would be very much appreciated.

Can IntelliJ Idea work with maven-failsafe-plugin tests?

According to the maven-failsafe-plugin's convention. integration tests need to be placed under src/it. This is all fine and dandy, but IntelliJ Idea doesn't:
Treat the code in src/it as test code
Let you run these tests through the UI
I have 2017.1.3 and I have also installed the Maven Test Support Plugin. Doesn't Idea support this kind of separation?

Cucumber is not recognizing defined steps "Undefined Steps"

I can't execute a simple test with cucumber for a project. I am on Intellij 13 Community, with cucumber plugin.
I wrote my feature file in my features directory, I have also implemented my steps creating them with the help of the plugin. My steps in the feature files are recognized by intellij, which can navigate and go to the step implementation.
When I try to run my scenario, if fails stating "Undefined step". Any help will be greatly appreciated.
Here is how i organized my project :
It sounds as if you are trying to run the feature from Idea. It also sounds as if you have some issue with the wiring of your project.
My approach would be to start with something that works and then modify it to suit your needs. A project that works is the Java skeleton provided by the Cucymber team. Download or clone it from GitHub: https://github.com/cucumber/cucumber-java-skeleton
You should be able to build this project using Maven, Ant, or Gradle. It will also be possible to open it using IntelliJ IDEA and modify it to suit your needs.

How to run assertion test when JUnit view is empty in Eclipse

I've been following along a couple of tutorials and at the point where they run the tests in the junit test view in Eclipse, mine just looks disabled, and I can see any tests to run:
Notice on the right hand side I have an empty JUnit view. None of the tutorials mention anything about this situation. You can see the JUnit library in my Package Explorer too. What do I need to do now to get my test to run in the JUnit test view?
You got the project setup right, now you need to tell eclipse to execute the test cases locate in the project, for that you need to do the following
Right click project --> run as --> Junit Test
And the Junit view of the eclipse will get populated with the test runs as below with the results of which cases failed and which passed
Just right click on AssertTest.java; then follow below--
run as > Junit Test
Since looking into your screen shot, you only have one Junit class; so it seems this will help you to run Junit.
I found this post while looking into a slightly different "empty JUnit view" issue: after upgrading to Eclipse 2022.06 from 2021.??, my JUnit view stopped working. I could see the unit tests running in the console, but no results were shown in the view.
I was able to fix it by opening the Eclipse preferences Java -> JUnit, then clicking Apply and Close.

Using SWTBot on a Maven Project

I am relatively new to SWTBot.
I have installed it through the "install new software" in eclipse.
I am trying to use it on an SWT application that was imported from an existing maven pom.xml. This application is not an eclipse plugin. Its just a standalone plain SWT application.
The problem is that I can't seem to be able to import any of SWTBot's classes in a test case.
I am wondering if there is a maven artefact I may need to add? I am not finding one.
If there is a more complex setup, how can I set it up?
if you installed the swtbot plugin/bundle via eclipse then you'll need an eclipse plugin project that depends on that bundle to hold your tests. Create a new plugin project and edit the manifest file to import the swtbot bundle.
You will then need a run configuration that will launch the application under test. I'm not sure how this can be achieved with a standalone maven project, but there's probably a way. If the project under test was an Eclipse application, you'd only need to right-click on your swtbot test and select run as swtbot test. I don't have an Eclipse with swtbot up and running atm so I can't give more detail, sry
[EDIT]
IMHO you should first try to test a dummy eclipse application. Put the plugin containing your test and the one containing your dummy app in your workspace, then run the test as described above. Once you have that running you should have a look at this post and the answer by the maintainer of SWTBot. A new instance of Eclipse will be launched with all UI contributions added by your dummy Eclipse application and the test will be run.
And have you already seen this similar post on SO? Sounds promising to me...

Categories