Skip to content

Commit

Permalink
#31, #33
Browse files Browse the repository at this point in the history
  • Loading branch information
kazurayam committed Jul 31, 2020
1 parent 6a7fc03 commit 345f84a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 45 deletions.
43 changes: 8 additions & 35 deletions Keywords/com/kazurayam/visualtesting/ImageDiffsLister.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class ImageDiffsLister {
List<Object> comparisonResultList = sortComparisonResultsByDiffRatio(slurper.parse(input_.toFile()))
//println JsonOutput.prettyPrint(JsonOutput.toJson(obj))
StringBuilder sb = new StringBuilder()
sb.append("|file name|diff|criteria|diff>criteria?|\n")
sb.append("|---------|------|---|---|\n")
sb.append("|file name|description|diff|criteria|diff>criteria?|\n")
sb.append("|---------|-----------|----|--------|--------------|\n")
for (entry in comparisonResultList) {
def href = entry.ComparisonResult.diffMaterial.Material.hrefRelativeToRepositoryRoot
List<String> pathElements = href.split('/') as List
Expand All @@ -41,6 +41,8 @@ public class ImageDiffsLister {
line.append('|')
line.append(fileName)
line.append('|')
line.append(entry.ComparisonResult.MaterialDescription.description.replace('|',' '))
line.append('|')
line.append(entry.ComparisonResult.diffRatio)
line.append('|')
line.append(entry.ComparisonResult.criteriaPercentage)
Expand All @@ -58,7 +60,7 @@ public class ImageDiffsLister {
List<Object> comparisonResultList = sortComparisonResultsByDiffRatio(slurper.parse(input_.toFile()))
//println JsonOutput.prettyPrint(JsonOutput.toJson(obj))
StringBuilder sb = new StringBuilder()
sb.append("file name,diff,criteria,diff>criteria?")
sb.append("file name,description,diff,criteria,diff>criteria?")
sb.append("\n")
for (entry in comparisonResultList) {
def href = entry.ComparisonResult.diffMaterial.Material.hrefRelativeToRepositoryRoot
Expand All @@ -67,6 +69,8 @@ public class ImageDiffsLister {
StringBuilder line = new StringBuilder()
line.append(fileName)
line.append(',')
line.append(entry.ComparisonResult.MaterialDescription.description.replace(',', ' '))
line.append(',')
line.append(entry.ComparisonResult.diffRatio)
line.append(',')
line.append(entry.ComparisonResult.criteriaPercentage)
Expand All @@ -78,38 +82,7 @@ public class ImageDiffsLister {
return sb.toString()
}

String toPs1() {
JsonSlurper slurper = new JsonSlurper()
List<Object> comparisonResultList = sortComparisonResultsByDiffRatio(slurper.parse(input_.toFile()))
//println JsonOutput.prettyPrint(JsonOutput.toJson(obj))
StringBuilder sb = new StringBuilder()
for (entry in comparisonResultList) {
String expectedHtmlPathStr = entry.ComparisonResult.expectedMaterial.Material.hrefRelativeToRepositoryRoot.replace('.png', '.html')
String actualHtmlPathStr = entry.ComparisonResult.actualMaterial.Material.hrefRelativeToRepositoryRoot.replace('.png', '.html')
Path expectedHtmlPath = Paths.get('.').resolve('Materials').resolve(expectedHtmlPathStr)
Path actualHtmlPath = Paths.get('.').resolve('Materials').resolve(actualHtmlPathStr)
if (Files.exists(expectedHtmlPath) && Files.exists(actualHtmlPath)) {
StringBuilder line = new StringBuilder()
line.append('# diff% ')
line.append(entry.ComparisonResult.diffRatio)
line.append('\n')
line.append('code --diff ')
line.append('\"')
line.append('./Materials/')
line.append(entry.ComparisonResult.expectedMaterial.Material.hrefRelativeToRepositoryRoot.replace('.png','.html'))
line.append('\"')
line.append(" ")
line.append('\"')
line.append('./Materials/')
line.append(entry.ComparisonResult.actualMaterial.Material.hrefRelativeToRepositoryRoot.replace('.png','.html'))
line.append('\"')
line.append("\n\n")
sb.append(line)
}
}
return sb.toString()
}


private List<Object> sortComparisonResultsByDiffRatio(Object obj) {
List<Object> comparisonResultList = obj.ComparisonResultBundle
comparisonResultList.sort { a, b ->
Expand Down
7 changes: 0 additions & 7 deletions Scripts/VT/reportImageDiffsList/Script1594099439779.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,3 @@ Path csv = misc.resolve('imageDiffsList.csv')
csv.toFile().write(lister.toCsv(), "utf-8")
WebUI.comment("${csv} has been created")

/**
* and a PS1 text (PowerShell script) as well
*/
Path ps1 = misc.resolve('imageDiffsList.ps1')
ps1.toFile().write(lister.toPs1(), "utf-8")
WebUI.comment("${ps1} has been created")

2 changes: 1 addition & 1 deletion VisualTestingInKatalonStudio.prj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UUID>da342c35-8895-46a8-bc71-707f2266a118</UUID>
<migratedVersion>5.9.0</migratedVersion>
<pageLoadTimeout>0</pageLoadTimeout>
<projectFileLocation>C:\Users\qcq0264\katalon-workspace\VisualTestingInKatalonStudio\VisualTestingInKatalonStudio.prj</projectFileLocation>
<projectFileLocation>/Users/kazuakiurayama/katalon-workspace/VisualTestingInKatalonStudio/VisualTestingInKatalonStudio.prj</projectFileLocation>
<sourceContent>
<sourceFolderList>
<sourceFolderConfiguration>
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

apply plugin: 'groovy'

version = "1.22.2"
version = "1.23.0"

ext {
groovyVersion = '2.4.7'
Expand All @@ -12,7 +12,7 @@ ext {
VT_DIST_COMPONENTS_PREFIX = 'vt-components'
VT_DIST_EXAMPLE_PREFIX = 'vt-example'

materialsVersion = '0.79.1'
materialsVersion = '0.80.0'
}

// ---------------------------------------------------------------------
Expand Down

0 comments on commit 345f84a

Please sign in to comment.