Closed RiccardoBoettcher closed 6 years ago
Hi @RiccardoInTheSun, thanks for your bug report. I already tried a lot of improvements within junt-datarprovider to get it working smoothly with IntelliJ IDEA. It seems that this hasn't helped so far but I will have a closer look again.
I having the same problem, any solution? Thanks
Hi @gaponte1985, hm ... unfortunately I have no real clue about IntelliJ but this can only be fixed by them, so I think we need to either investigate our own or open an issue at their issue tracker ...
Do you have experience with debugging IntelliJ itself?
Hi @gaponte1985,
it seems that your loaded dependencies is broken / empty or was not resolved properly somehow. Can you search for the dependency in "External library" folder on the "Project" tool window? What does the package com.tngtech.java.junit.dataprovider
show?
In Addition some hints: You should use the newest version of junit-dataprovider 1.12.0 instead of 1.10.0. Also the used String
in @UseDataProvider
annotation will never work. It requires a method name as String
(mandatory) and optional a Class
specified e.g. like BrowserComboDP.class
without "
.
Cheers, Andreas
Can it be becuase I using java 8 and this class was compile in java 6?
No, we also use junit-dataprovider with java8 already ...
Hm ... very strange ... can you run mvn clean install
and paste the command line output? Is your project some kind of open source such that I can check it out myself?
I was able to make it worked not sure how but i have a other question went you say "Also the used String in @UseDataProvider annotation will never work. It requires a method name as String (mandatory) and optional a Class specified e.g. like BrowserComboDP.class without ". what do you meant for example I trying to test the following scenario....
import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; import com.tngtech.java.junit.dataprovider.UseDataProvider; import org.junit.Test; import org.junit.runner.RunWith;
/**
@RunWith(DataProviderRunner.class) public class GreedyDataProviderExample { @DataProvider(value = "data-source") public Object[][] allDataInOneShot() { return new Object[][] { { "Java" }, { "TestNG" }, { "JUnit" } }; }
@Test
@UseDataProvider (GreedyDataProviderExample.class)
public void myTestMethod(String info) {
System.out.println("Data provided was :" +info);
}
}
Hi @gaponte1985,
great to hear that you got it working :-)
Sorry for the not precise formulation. Here is your example from above as it should work:
@RunWith(DataProviderRunner.class)
public class GreedyDataProviderExample {
@DataProvider(value = "data-source") // "value =" is optional and can be removed if you want
public Object[][] allDataInOneShot() {
return new Object[][] { { "Java" }, { "TestNG" }, { "JUnit" } };
}
@Test
@UseDataProvider(value = "data-source", location = GreedyDataProviderExample.class) // "location = GreedyDataProviderExample.class" is optional as by default the corresponding dataProvider is search in the same class
public void myTestMethod(String info) {
System.out.println("Data provided was :" +info);
}
}
You can also avoid the explicit mentioning of the dataproviders name by using on of the documented conventions from https://github.com/TNG/junit-dataprovider/wiki/Features#convention-over-configuration.
Hope this helps & clarifies, Andreas
Thanks it works!!!!
IntelliJ is now using JUnit Platform to execute test case. This fixed the double-click issue. Unfortunately, IntelliJ is still not able to run a single dataprovider test.
Note: Eclipse was able to do this with JUnit4 but now it also seems not to work which let's me assume that this is maybe a JUnit platform issue. -> I will check :-)
This seems to be a problem with JUnit5, see https://github.com/junit-team/junit5/issues/1025. As soon as this is solved, Eclipse (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=520923) and IntelliJ should work properly using UniqueId
s.
Therefore, I will close this defect as it is no longer a problem JUnit dataprovider implementation can solve!
Problem IntelliJ Idea is not able to run/debug individual (instances) of parametrized test methods, nor is it possible to directly jump to the definition of the test method by clicking in the JUnit window.
Analysis This is a problem of Idea as the internal implementation is tightly bound the the default parametrized test runner of JUnit.
Proposal May be there is a way to define an API / interface together with JUnit which then can be used by Idea to get exact information about parametrized tests independent of the used approach and/or TestRunner. The other way to fix it: Provide a patch for Idea which treats the DataProviderRunner in the same way like the JUnit runner and hope it finds it way into a future release of Idea.
I know this very unspecific to be a direct JUnit-DataProvider feature request, but the bad integration in Idea is annoying and I'm really interested in getting it fixed at same day.