Cucumber and Eclipse IDE; How to make jar for a test case - eclipse

I'm a Cucumber and Eclipse beginner and have a few questions and hope you can help me to get through this: I created a sample cucumber test scenario, a sample test steps and a cucumber runner. The scenarios runs fine within eclipse IDE (Neon). I used Maven as the dependency manager. I also installed the Maven command line module. The step code is Java.
Here is the (basic) question: How do I create a jar file from my cucumber test scenario so that execute it via command line so that I can bring the test scenario to Jenkins CI? Is there anything I need to do with Maven BEFORE I can build the jar file?
Thanks a lot folks!

If you run Cucumber using the JUnit runner, then all you have to do to run from a command line is to execute Maven and make sure you invoke a life cycle phase that includes running the unit tests. One way would be
mvn test
An example that might get you up and running can be found at
https://github.com/cucumber/cucumber-java-skeleton

Related

KIE Workbench Test Scenarios as a part of Maven build

In my current project we need to run Test Scenarios created in Workbench as a part of a Maven build. The final goal is to have these functional tests included to the continuous integration process.
We spent a couple of days trying to figure it out.
We opened a project that is created by Workbench in the .niogitfolder and are trying to run a maven goal.
But seems that maven goals like mvn clean install or mvn clean verify or mvn clean test don't run the Test Scenarios having a .scenario type at all.
Do you have any ideas on that?
Test scenarios are specific to kie-workbench. maven commands will not execute them during build. If you want tests to be executed during maven build then you have to write junit tests to check the execution of rules and processes.
there is currently work in progress on new version of scenarios in the kie-workbench. See the list of tasks. I would recommend you to bring this requirement there.

SBT/Scala and Integration testing

While researching on the subject of automating my integration tests, I found out a nice plugin in the maven world called FailSafe. it gives me phases like pre-integration-test, post-integration-test and integration-test.
By tying into these phases, I can have other plugins which can start/stop and run docker images.
The plugin also has a nice way in which I can differentiate between UnitTests and IntegrationTests (even though both are written in JUNIT).
Well now the question is how can I do the same thing with Scala / SBT combination?
my requirement is
Write Integration tests in SpecFlow.
Integration tests are treated differently than unit tests.
First Unit Tests are run.
Then docker containers are created and run
then integration tests are run.
docker contains are shut-down.
test results are captured in files. (just like surefire/failsafe plugins).
Is this possible in Scala/sbt combo?
A simple solution is to run $ sbt "~ it:test" (make sure integration test are in a package named 'it') for integration test which will automatically run every time source code is updated. Furthermore, $sbt "~ test" for automated unit testing. If you are using a IDE such as IntelliJ IDEA, you can make it easier to run this in a custom configuration from the IDE. Hope this helps a little bit. I run these all the time when working.
I found the answer to the question. SBT provides means to do integration test and also setup and cleanup methods to do things like creation / destruction of docker containers
http://www.scala-sbt.org/0.13/docs/Testing.html

Run appium test on command line

Currently I am running Appium tests using Run as -> TESTNG TEST on Eclipse. I want to do the same using command line. Anyone can explain how to do this?
To execute test using command line, you can use Build tool like Ant or gradle.
Sample testng example using Ant you can find here, https://github.com/amitbhoraniya/TestNG.
You can take reference from here and can create your own task.
Official Documentation of testng ant task you can find here. TestNg-Ant
To run tests using gradle, you can find example here
https://github.com/amitbhoraniya/GradleTestNg

My jar won't add my junit tests

The contents of my jar file does not contain my junit tests. I tried creating a main class that calls my tests with "Junit Core" but that too doesn't get added to my jar file. What am I missing?
Your production package (your jar) is not supposed to contain the test code (your unit tests).
Test code is supposed to be invoked only when the tests are been executed.
You shouldn't do it, but if you want the test code to be included in your package just put it in the same root folder of your production code. Ex: if you are using Maven, your folders structure might be something like this:
project_name/src/main/java/
-> production code
project_name/src/test/java/
-> test code
In that case, change it to:
project_name/src/main/java/
-> production code
-> test code
Be aware that doing that you will have some problems, like the tests not executing during a normal build. We might help you better if you put a question asking how to accomplish your goal (what is your goal?).
Update based on the goal explained in the comments: Would be better if this tool (Silk Central) could run your tests using Maven or Ant, and I'm pretty sure it can.
I've been used different tools to run my Junit (or other XUnit frameworks) tests. What I do is to configure the tool to:
Get the source code from the version control.
Run the build/tests by calling Maven or Ant installed along the tool.
Read the Junit outputs.
Sometimes the tool has its own integration with Junit and you don't have even to use Maven or Ant.
I mean, your central build or tests tool should be able to run your tests just like you do in your own machine.
Take a look on this or search by "Silk Central junit" in the web:
http://community.microfocus.com/borland/test/silk_central/w/wiki/465.zero-maintenance-junit-testing-using-classpathsuite-in-sctm.aspx

How do I create a self contained package of Selenium JUnit Tests?

I have a bunch of Selenium Tests which I currently run on JUnit from Eclipse. (Using the Firefox webDriver)
I need to create an easy to install/use package of these tests to give to various members of the QA team so they can run them on different computers.
Is there something that already does this, is there a way to zip up eclipse + tests so they can be run from any computer?
Yes there are a couple of ways
I use maven for managing the project dependencies and run the tests via sure-fire plugin... but it looks like an overkill for your case
You can see a simple explanintion here:
how to export (JUnit) test suite as executable jar