How you do this depends on which integration server and IDE you use and what you use. Suppose you are using Eclipse; and I will assume that you are using Jenkins , as this will be IMO the easiest to get it to do what you want.
Most of this will work out of the box. However, there is little that will require some extra work.
You want to do the following:
- Set up Jenkins by naming something like "Integrated Testing" (the name doesn't matter). Configure it to run the tests you want to run from the IDE and to allow remote computers to run assemblies.
- Make this task parameterized and add a file parameter. Suppose this is called a "TestingProgram". This will be the program that the task will check.
- The Integrated Testing job task uses the TestingProgram file to run tests. If the program requires more than one file, then suppose that it is a zip file containing all the necessary files.
- Set up your Eclipse project to create the same files (s) that are awaiting integration test results (I assume this is already happening, as it seems to be creating some kind of bin version of your program)
Now comes the slightly more complicated part of connecting Eclipse to Jenkins. Unfortunately, I donβt think there are any preexisting tools that will do exactly what you want. The good news is that with a custom script this should be very simple. All script should:
- If your program has several required files, and eclipse does not do this yet, you will need to pin these files to
- He will need to take the file and read it in some variable, and then base64 encode it. There are many libraries that will take care of this for you, like this one . Suppose this file is read into a variable named
$programFile - He will need to send an HTTP request to
http://<your-jenkins-server>:8080/<integrated-testing-job-name>/buildwithparameters?TestingProgram=$programFile
You can read more about running remote Jenkins builds with options in denkins docs .
The script that follows these steps can be almost anything. Given that you want to eventually include it in your IDE, it seems that the most logical choice would be an ant script or an Eclipse plugin. None of them will be too complicated: the ant script will perform these actions, and you can import the ant script into the Eclipse project specifically for testing - and the plugin can simply add a menu item that, when launched as part of the project, will perform the above steps to do this project.
NOTE. There are several different ways to start an assembly with parameters using Jenkins. For example, you can execute a POST request, use json to pass the parameter, as described in the jenkins docs I am linked to, use the Jenkins CLI, etc. Not all of them work with file parameters, but you will use them all in one very similarly - as a step in a user script, you must perform remote assembly on Jenkins and transfer the file that you want to use for testing. For example, the explanation I gave suggests that the test file is very small; if this is not the case, you may want to execute a POST request. If you are having problems using one method, it's pretty easy to switch it to use another method that works better.
Laepdjek
source share