I have made a demo project in GitHub.
Problems to solve
(1) I want to use Amazon S3 in my test cases
My Visual Testing in Katalon Studio project enabled me to do visual regression testing. It compares 2 URLs of my AUT (production & development) visually in a time-slicing manner.
Now I have a plan to develop new way of visual regression testing. It would be a chronological approach. The new project will compare screen shots of the current AUT with another set of screen shots taken previously — taken 3 hours ago, taken yesterday evening, or taken last week. Chronological visual regression testing would enable me to ensure the system’s stability before/after the AUT changes in production. I would be able to automatically compare hundreds of pages against the previous images taken before/after the change.
But this new idea raises an issue to me. I need to store a lot of versions of screen shot sets. Driving the chronological test in a Continuous Integration system, for example once a day, will result huge number of screen shot files (over 10000 easily). How can I manage the accumulated screen shot files? One idea has come up to my mind. Why not using Cloud Storage service such as Amazon S3?
Cloud Storage seems to be promising for me. With it, I do not have to worry about the capacity, it’s cheap, files older than 1 month will be automatically deleted, … etc.
Therefore I want to call AWS Java SDK for S3 in Katalon Studio so that my test case can transport screenshot files to and from Amazon S3.
(2) How to resolve external dependencies?
AWS document provides enough information how to use AWS Java SDK for S3 in my Java/Groovy codes. So I tried to write a test case in Groovy in Katalon Studio which calls AWS API for S3. I wanted to list my S3 Buckets in my AWS account. Soon I encountered a blocking problem.
Katalon Studio requires all of the external dependencies (jar files) put into the <projectDir>/Drivers
directory. I knew I need the aws-java-sdk-s3-1.11.470.jar
. But there are a lot more dependencies (in fact 14 jars). Unfortunately Katalon Studio does not provide any dependency management.
A quote from Gradle document
What is dependency management?
Software projects rarely work in isolation. In most cases, a project relies on reusable functionality in the form of libraries or is broken up into individual components to compose a modularized system. Dependency management is a technique for declaring, resolving and using dependencies required by the project in an automated fashion.
It looked impossible for me to look up all the necessary jar files for running a test case with AWS SDK in Katalon Studio.
Solution
Use com.katalon.gradle-plugin
.
Sample build.gradle
is here
$ gradle katalonCopyDependencies
the plugin lets Gradle download the specified jar file and other dependencies from the Maven Central repository, and it copies them into the <projectDir>/Drivers
directory. For example, I got:
$ ls Drivers
katalon_generated_aws-java-sdk-core-1.11.470.jar
katalon_generated_aws-java-sdk-kms-1.11.470.jar
katalon_generated_aws-java-sdk-s3-1.11.470.jar
katalon_generated_commons-codec-1.10.jar
katalon_generated_commons-logging-1.2.jar
katalon_generated_httpclient-4.5.5.jar
katalon_generated_httpcore-4.4.9.jar
katalon_generated_ion-java-1.0.2.jar
katalon_generated_jackson-annotations-2.6.0.jar
katalon_generated_jackson-core-2.6.7.jar
katalon_generated_jackson-databind-2.6.7.2.jar
katalon_generated_jackson-dataformat-cbor-2.6.7.jar
katalon_generated_jmespath-java-1.11.470.jar
katalon_generated_joda-time-2.8.1.jar
Description
Prerequisite
Here I assume you have some experience of AWS. You should already have an AWS account for you; you already have prepared AWS credential info in the <HOME>/.aws
directory of your PC; you should have installed AWS CLI. I assume you can successfully do the following operation in the command line:
$ aws s3 ls
2017-12-27 06:30:04 myBucket1
2016-03-31 23:11:02 myBucket2
2015-03-01 13:01:59 myBucket3
...
I am going to do the same operation (list my S3 Buckets) by a groovy script as test case in Katalon Studio.
Resolving dependencies
Here I assume you have got started with Gradle. Installation guide is here.
I added <projectDir>/build.gradle
file. In there I declared only one jar as dependency of the project.
dependencies {
// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3
compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.470'
}
You can find the jar in the Maven Central repository https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3
I the command line, I executed the following command:
$ cd <katalon project path>
$ gradle katalonCopyDependencies
Gradle took a few minutes to finish the katalonCopyDependencies
task. It downloaded 14 jar files into the local <HOME>/.m2
diretory — this took a few minutes. And the task copied necessary jar files into <projectDir>/Drivers
.
I closed the project once, and reopened it in Katalon Studio. This was necessary in order to let Katalon Studio acknowledge the new jar files in the Drivers directory.
Now I run it
I wrote a test case ListMyS3Buckets.
I ran the test case, and got the following output:
My Amazon S3 buckets are:
* myBucket1
* myBucket2
* myBucket3
...
It worked.
Note on .gitignore
If you are using git for the Katalon project, you should exclude the external jar files out of the repository by adding the following line in the .gitignore
file.
/Drivers