final class ImageCollectionDiffer extends ImageCollectionProcessor
This class is designed to implement the "Visual Testing in Katalon Studio" feature. This class uses the following 2 external libraries: 1. AShot (https://github.com/yandex-qatools/ashot) 2. Materials (https://github.com/kazurayam/Materials) The makeImageCollectionDifferences() method provides the core value of this class. This method accepts Materials (image files) to compare them, make differences, and store the diff-images into files.
| Fields inherited from class | Fields |
|---|---|
class ImageCollectionProcessor |
filenameResolver_, vtLogger_ |
| Type | Name and description |
|---|---|
static org.slf4j.Logger |
logger_ |
| Constructor and description |
|---|
ImageCollectionDiffer
(MaterialRepository mr)constructor |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static MaterialPair |
decorateMaterialPair(MaterialPair source, TSuiteResult expectedTSR, TSuiteResult actualTSR)Check the source MaterialPair has an orphan, which means if it lacks the Expected Material or it lacks the Actual Material. |
|
void |
endImageCollection(TCaseName tCaseName)serialize the list of EvaluationResult objects into file. |
|
void |
endMaterialPair(ComparisonResult cr) |
|
static java.lang.Object |
fakeMaterial(TSuiteResult targetTSuiteResult, Material existingMaterial)@param targetTSuiteResult e.g, '. |
|
MaterialDescription |
findMaterialDescription(TSuiteResult tSuiteResult, Material material)MaterialMetadataBundle file may look like as this:
{
"MaterialMetadataBundle": [
|
|
java.nio.file.Path |
getOutput()@return the Path of comparison-result-bundle.json file created by endImageCollection() method call. |
|
boolean |
makeImageCollectionDifferences(MaterialPairs materialPairs, TCaseName callerTCaseName, ImageDeltaStats imageDeltaStats)@param materialPairs |
|
boolean |
makeImageCollectionDifferences(MaterialPairs materialPairs, TCaseName callerTCaseName, double criteriaPercentage)compare 2 Material files in each MaterialPair object, create ImageDiff and store the diff image files under the directory |
|
static java.awt.image.BufferedImage |
makeMarkerImage(java.nio.file.Path pathNotFound)make a Marker image which shows """File not found: C: └─Users └─qcq0264 └─eclipse-workspace |
|
void |
setImageDifferenceFilenameResolver(ImageDifferenceFilenameResolver filenameResolver) |
|
void |
setVisualTestingLogger(VisualTestingLogger logger)set instance of VisualTestingListener, which will consume messages from ImageCollectionDiffer |
|
void |
startImageCollection(TCaseName tCaseName)prepare File of 'comparison-result.json' |
|
ComparisonResult |
startMaterialPair(TCaseName tCaseName, MaterialPair materialPair, double criteriaPercentage, MaterialDescription materialDescription)This method is the core part of ImageCollectionDiffer. |
| Methods inherited from class | Name |
|---|---|
class ImageCollectionProcessor |
makeImageCollectionDifferences, makeImageCollectionDifferences, setImageDifferenceFilenameResolver, setVisualTestingLogger |
constructor
Check the source MaterialPair has an orphan, which means if it lacks the Expected Material or it lacks the Actual Material. Fill the vacancy with a Material object which returns fileExists()==false
serialize the list of EvaluationResult objects into file.
targetTSuiteResult - e.g, './Materials/main.TS1/20180530_130419/'existingMaterial - e.g, './Materials/main.TS1/20180530_150000/main.TC1/foo/bar/fixture.xls'MaterialMetadataBundle file may look like as this:
{
"MaterialMetadataBundle": [
...
{
"MaterialMetadata": {
"MaterialPath": "CURA.chronos_capture/CURA_DevelopmentEnv/20200729_130109/CURA.visitSite/screenshots/profile.php%23login.png",
"TCaseName": "Test Cases/CURA/visitSite",
"MaterialDescription": {
"category": "1",
"description": "Login page"
},
"InvokedMethodName": "resolveScreenshotPathByUrlPathComponents",
"SubPath": "screenshots",
"URL": "https://katalon-demo-cura.herokullogin"
}
},
Material may look like this:
{
"url": "null",
"suffix": "",
"fileType": {
"FileType": {
"extension": "png",
"mimeTypes": [
"image/png"
]
}
},
"path": "/Users/kazuakiurayama/katalon-workspace/VisualTestingInKatalonStudio/Materials/CURA.chronos_capture/CURA_DevelopmentEnv/20200729_130109/CURA.visitSite/screenshots/profile.php%23login.png",
"hrefRelativeToRepositoryRoot": "CURA.chronos_capture/CURA_DevelopmentEnv/20200729_130109/CURA.visitSite/screenshots/profile.php%23login.png",
"lastModified": "2020-07-29T04:02:06",
"de_130109"
}
Given above two arguments, find a MaterialDescription of the Material and return:
{
"category": "1",
"description": "Login page"
}
compare 2 Material files in each MaterialPair object,
create ImageDiff and store the diff image files under the directory
./Materials/materialPairs - created by
com.kazurayam.materials.MaterialRpository#createMaterialPairs() methodtCaseName - the name of test case which called the ImageCollectionDiffer#makeImageCollectionDifferences()criteriaPercent - e.g. 3.00 percent. If the difference of
a MaterialPair is greater than this,
the MaterialPair is evaluated FAILED
make a Marker image which shows """File not found: C: └─Users └─qcq0264 └─eclipse-workspace ... """
set instance of VisualTestingListener, which will consume messages from ImageCollectionDiffer
prepare File of 'comparison-result.json'
This method is the core part of ImageCollectionDiffer.
Groovy Documentation