kazurayam / materialstore

A domain-specific file system to store "materials" (screenshots, HTML, JSON, XML) collected during End-to-End testings using Selenium WebDriver etc. Features to make "diff" and compiling HTML reports are also included. This is written in pure Java8
Apache License 2.0
0 stars 0 forks source link

Reducer should not throw MaterialstoreException when the store and store-base dire is not present #389

Closed kazurayam closed 1 year ago

kazurayam commented 1 year ago

derived from https://github.com/kazurayam/inspectus4katalon-sample-project/issues/8

2022-12-12 16:53:47.870 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/CURA/main FAILED.
Reason:
com.kazurayam.inspectus.core.InspectusException: com.kazurayam.materialstore.core.filesystem.MaterialstoreException: store.reflect(currentMaterialList) returned previousMaterialList of size == 0. currentMaterialList = CURA/20221212_165311
    at com.kazurayam.inspectus.core.internal.ChronosDiff.step3_reduceChronos(ChronosDiff.java:86)
    at com.kazurayam.inspectus.core.internal.ChronosDiff.process(ChronosDiff.java:28)
    at com.kazurayam.inspectus.core.Inspectus.execute(Inspectus.java:8)
    at com.kazurayam.inspectus.core.Inspectus$execute.call(Unknown Source)
    at main.run(main:38)
    at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
    at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
    at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:445)
    at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:436)
    at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:415)
    at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:407)
    at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:284)
    at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
    at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
    at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
    at TempTestCase1670831587859.run(TempTestCase1670831587859.groovy:25)
Caused by: com.kazurayam.materialstore.core.filesystem.MaterialstoreException: store.reflect(currentMaterialList) returned previousMaterialList of size == 0. currentMaterialList = CURA/20221212_165311
    at com.kazurayam.materialstore.base.reduce.Reducer.chronos(Reducer.java:72)
    at com.kazurayam.materialstore.base.reduce.Reducer.chronos(Reducer.java:44)
    at com.kazurayam.materialstore.base.reduce.Reducer.chronos(Reducer.java:24)
    at com.kazurayam.inspectus.core.internal.ChronosDiff.step3_reduceChronos(ChronosDiff.java:68)
    ... 15 more

2022-12-12 16:53:47.879 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/CURA/main

When the store and store-backup directory is not present and ChronosDiff ran, an MaterialstoreException will be raised. Because of this code:

Reducer Line No.70

        if (previousMaterialList.size() == 0) {
            throw new MaterialstoreException(
                    String.format("store.reflect(currentMaterialList) returned previousMaterialList of size == 0. " +
                            "currentMaterialList = %s/%s", currentMaterialList.getJobName().toString(),
                            currentMaterialList.getJobTimestamp().toString()));
        }

Is this check necessary?

It is better not to perform this check = do not throw Exception, and the Reducer silently performs comparison a real material against a void materia, resulting 100% diff.

kazurayam commented 1 year ago

I found that the test coverage of com.kazurayam.materialstore.base.inspector.InspectorTest class + reduceAndSort() method is not versatile enough.

スクリーンショット 2022-12-12 18 51 01

I should extend the InspectorTest first

kazurayam commented 1 year ago

Reducer#chronos() method implementation had a code:

        if (previousMaterialList.size() == 0) {
            throw new MaterialstoreException(
                    String.format("store.reflect(currentMaterialList) returned previousMaterialList of size == 0. " +
                            "currentMaterialList = %s/%s", currentMaterialList.getJobName().toString(),
                            currentMaterialList.getJobTimestamp().toString()));
        }

This was just unnecessary.

I removed it.