Reputation: 9191
I am trying to come up with an idea on how to create a Cucumber Test on Docker Executable Image?
public class GenerateNumber {
public static void main(String[] args) {
if (args != null && args.length > 0) {
String input = args[0];
if(input.equals("ODD")) {
//GENERATE ODD NUMBERS FROM 0 TO 1000
}else {
//GENERATE EVEN NUMBERS FROM 0 TO 1000
}
}
}
}
Supposed I have this simple class file...I am packaging it into an executable Jar File and use this class as an entry point in my application. The java file is deployed as a containerized image that will run my class.
Now, from a Cucumber Test perspective, how do I create a step definition file for such case?
This is a docker image right? I am coming up with a strategy on how to do this test. Any hints from someone who have done similar requirements?
Upvotes: 0
Views: 2207
Reputation: 3065
It is a little hard to understand what you are trying to achieve
If your docker image is a 'black box' that executes, and you need to analyse the result, you would have to build a separate cucumber test project that would execute on the host.
The cucumber step definitions methods could call methods that can start the docker image, log in to the container, pull files out, read logs etc, which can then be asserted against. You could use the Spotify docker client libraries to do that.
Upvotes: 0
Reputation: 4323
How you connect to your example depends on when you want to verify that it works.
My strategy would be to do it during build time of the application. This reduces Docker from the equation and any Java tutorial on Cucumber will be applicable. I have plenty of tutorials on my blog. Maybe this post can be of some help. Use modern versions of the tools.
If you want to connect to the application from a Cucumber step when the application runs in Docker, you need some way to do the connection. This is the same as connecting to any server application from the outside. An example could be to drive Selenium from Cucumber steps and and verify a web application. This post may be of help to understand how you can verify different types of applications. Again a bit dated, but the ideas have stayed the same.
Upvotes: 1