I inherited java maven project composed of cucumber, junit and selenium frameworks which I am new to except Junit. I noticed its pkg name is under src/test/java instead of src/main/java.
src/test/java
com.somewhere.test
FooRunner.java
I was told that I can run junit test from FooRunner class by right click Run as > Junit Test in eclipse IDE.
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/resources/com/sowhere/test/features",tags = {"@Test"}, plugin = {
"pretty",
"junit:target/results.xml",
"html:target/cucumber"},
dryRun = false)
public class FooRunner {
public static void main(String[] args) {
}
}
I was able to run its unit test just fine. My question is I need this mvn project to generate executable jar file then be able to run its unit test from
java -jar Foo.jar
I followed this thread to Running Cucumber tests directly from executable jar by updating pom.xml file and adding public static void main method however when I executed the jar file I received following error msg..
Error: Could not find or load main class com.somewhere.test.FooRunner
I changed jar to zip then unpacked it all. Surprisingly I didn't see pkg name com.somewhere.test but I see other pkgs of external libraries such as cucumber and etc. Yes META-INF/MANIFEST.MF is there with proper data I believe.
I am curious to know why the pkg (i.e. com.somewhere.test) is missing along with class (i.e. FooRunner.class)
Update:
I found an answer from this thread: How can I include test classes into Maven jar and execute them?