Cannot invoke method getTCaseResultList() on null object

Hi @kazurayam, sorry for the directly mention.
We’re using your Visualtesting with katalon (thank you for your great works!!)… and we are facing a trouble.

My tests are passed in Mac OS but it fails in Windows. (we want to use it in azure DevOps, it fails both in DevOps and virtual Windows env.)

What are the possible reasons?
I think it fails when getting the location of “Storage” (and “Report”) folder… but they are exist at the same project.

I’m a beginner for automation, so please let me know if you need more information.

2019-12-24 06:38:38.882 INFO  com.kms.katalon.core.util.KeywordUtil    - VisualTestingListenerImpl#beforeTestSuite testSuiteTimestamp=20191224_063826
2019-12-24 06:38:38.977 ERROR c.k.k.core.context.internal.TestHooker   - ❌ java.lang.NullPointerException: Cannot invoke method getTCaseResultList() on null object
	at com.kazurayam.materials.impl.TSuiteResultImpl$getTCaseResultList$5.call(Unknown Source)
	at com.kazurayam.materials.repository.RepositoryFileVisitor.resolveLastModifiedOfTSuiteResult(RepositoryFileVisitor.groovy:233)
	at com.kazurayam.materials.repository.RepositoryFileVisitor.postVisitDirectory(RepositoryFileVisitor.groovy:136)
	at com.kazurayam.materials.repository.RepositoryFileVisitor.postVisitDirectory(RepositoryFileVisitor.groovy)
	at java_nio_file_Files$walkFileTree.call(Unknown Source)
	at com.kazurayam.materials.repository.RepositoryFileScanner.scan(RepositoryFileScanner.groovy:109)
	at com.kazurayam.materials.repository.RepositoryFileScanner$scan.call(Unknown Source)
	at com.kazurayam.materials.impl.MaterialRepositoryImpl.scan(MaterialRepositoryImpl.groovy:95)
	at com.kazurayam.materials.impl.MaterialRepositoryImpl.<init>(MaterialRepositoryImpl.groovy:78)
	at com.kazurayam.materials.impl.MaterialRepositoryImpl.newInstance(MaterialRepositoryImpl.groovy:88)
	at com.kazurayam.materials.impl.MaterialRepositoryImpl$newInstance.call(Unknown Source)
	at com.kazurayam.materials.MaterialRepositoryFactory.createInstance(MaterialRepositoryFactory.groovy:33)
	at com.kazurayam.materials.MaterialRepositoryFactory$createInstance.call(Unknown Source)
	at com.kazurayam.materials.impl.MaterialStorageImpl.<init>(MaterialStorageImpl.groovy:45)
	at com.kazurayam.materials.impl.MaterialStorageImpl.newInstance(MaterialStorageImpl.groovy:55)
	at com.kazurayam.materials.impl.MaterialStorageImpl$newInstance.call(Unknown Source)
	at com.kazurayam.materials.MaterialStorageFactory.createInstance(MaterialStorageFactory.groovy:19)
	at com.kazurayam.materials.MaterialStorageFactory$createInstance.call(Unknown Source)
	at com.kazurayam.visualtesting.VisualTestingListenerImpl.beforeTestSuite(VisualTestingListenerImpl.groovy:160)
	at com.kazurayam.visualtesting.VisualTestingListenerImpl$beforeTestSuite.call(Unknown Source)
	at VTListener.beforeTestSuite(VTListener.groovy:19)
	at VTListener.invokeMethod(VTListener.groovy)
	at com.kms.katalon.core.context.internal.TestHooker.invokeMethod(TestHooker.java:111)
	at com.kms.katalon.core.context.internal.TestHooker.lambda$3(TestHooker.java:95)
	at com.kms.katalon.core.context.internal.TestHooker.invokeContextMethods(TestHooker.java:94)
	at com.kms.katalon.core.context.internal.TestListenerCollector.lambda$3(TestListenerCollector.java:88)
	at com.kms.katalon.core.context.internal.TestListenerCollector.handleListenerEvent(TestListenerCollector.java:85)
	at com.kms.katalon.core.context.internal.ExecutionEventManager.publicEvent(ExecutionEventManager.java:36)
	at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:89)
	at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
	at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
	at TempTestSuite1577169506664.run(TempTestSuite1577169506664.groovy:36)

2019-12-24 06:38:39.206 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2019-12-24 06:38:39.207 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/VT/cleanMaterials
2019-12-24 06:38:39.398 INFO  c.k.k.c.keyword.builtin.CommentKeyword   - VisualTestingListenerImpl#beforeTestCase GlobalVariable.VT_CURRENT_TESTSUITE_ID is "Test Suites/VisualTest/VT/cleanMaterials"
2019-12-24 06:38:39.413 INFO  c.k.k.c.keyword.builtin.CommentKeyword   - VisualTestingListenerImpl#beforeTestCase GlobalVariable.VT_CURRENT_TESTSUITE_TIMESTAMP is "20191224_063826"
2019-12-24 06:38:39.413 INFO  c.k.k.c.keyword.builtin.CommentKeyword   - VisualTestingListenerImpl#beforeTestCase GlobalVariable.VT_CURRENT_TESTCASE_ID is "Test Cases/VT/cleanMaterials"
2019-12-24 06:38:39.413 INFO  c.k.k.c.keyword.builtin.CommentKeyword   - VisualTestingListenerImpl#beforeTestCase GlobalVariable.VT_MATERIAL_REPOSITORY is located at "C:\Users\Administrator\katalon-ui-test\XXXXX\Materials"
Start recording video for test case 'Test Cases/VT/cleanMaterials'.
2019-12-24 06:38:39.429 ERROR c.k.k.core.context.internal.TestHooker   - ❌ java.lang.NullPointerException: Cannot invoke method getTCaseResultList() on null object
	at com.kazurayam.materials.impl.TSuiteResultImpl$getTCaseResultList$5.call(Unknown Source)
	at com.kazurayam.materials.repository.RepositoryFileVisitor.resolveLastModifiedOfTSuiteResult(RepositoryFileVisitor.groovy:233)
	at com.kazurayam.materials.repository.RepositoryFileVisitor.postVisitDirectory(RepositoryFileVisitor.groovy:136)
	at com.kazurayam.materials.repository.RepositoryFileVisitor.postVisitDirectory(RepositoryFileVisitor.groovy)
	at java_nio_file_Files$walkFileTree.call(Unknown Source)
	at com.kazurayam.materials.repository.RepositoryFileScanner.scan(RepositoryFileScanner.groovy:109)
	at com.kazurayam.materials.repository.RepositoryFileScanner$scan.call(Unknown Source)
	at com.kazurayam.materials.impl.MaterialRepositoryImpl.scan(MaterialRepositoryImpl.groovy:95)
	at com.kazurayam.materials.impl.MaterialRepositoryImpl.<init>(MaterialRepositoryImpl.groovy:78)
	at com.kazurayam.materials.impl.MaterialRepositoryImpl.newInstance(MaterialRepositoryImpl.groovy:88)
	at com.kazurayam.materials.impl.MaterialRepositoryImpl$newInstance.call(Unknown Source)
	at com.kazurayam.materials.MaterialRepositoryFactory.createInstance(MaterialRepositoryFactory.groovy:33)
	at com.kazurayam.materials.MaterialRepositoryFactory$createInstance.call(Unknown Source)
	at com.kazurayam.materials.impl.MaterialStorageImpl.<init>(MaterialStorageImpl.groovy:45)
	at com.kazurayam.materials.impl.MaterialStorageImpl.newInstance(MaterialStorageImpl.groovy:55)
	at com.kazurayam.materials.impl.MaterialStorageImpl$newInstance.call(Unknown Source)
	at com.kazurayam.materials.MaterialStorageFactory.createInstance(MaterialStorageFactory.groovy:19)
	at com.kazurayam.materials.MaterialStorageFactory$createInstance.call(Unknown Source)
	at com.kazurayam.visualtesting.VisualTestingListenerImpl.beforeTestCase(VisualTestingListenerImpl.groovy:208)
	at com.kazurayam.visualtesting.VisualTestingListenerImpl$beforeTestCase$0.call(Unknown Source)
	at VTListener.beforeTestCase(VTListener.groovy:25)
	at VTListener.invokeMethod(VTListener.groovy)
	at com.kms.katalon.core.context.internal.TestHooker.invokeMethod(TestHooker.java:111)
	at com.kms.katalon.core.context.internal.TestHooker.lambda$3(TestHooker.java:95)
	at com.kms.katalon.core.context.internal.TestHooker.invokeContextMethods(TestHooker.java:94)
	at com.kms.katalon.core.context.internal.TestListenerCollector.lambda$3(TestListenerCollector.java:88)
	at com.kms.katalon.core.context.internal.TestListenerCollector.handleListenerEvent(TestListenerCollector.java:85)
	at com.kms.katalon.core.context.internal.ExecutionEventManager.publicEvent(ExecutionEventManager.java:36)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:219)
	at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:169)
	at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:142)
	at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:91)
	at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
	at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
	at TempTestSuite1577169506664.run(TempTestSuite1577169506664.groovy:36)

@rie.ota

Thank you very much for your interest to my product.

I have no idea. The VisualTestingInKatalonStudio project has no OS-dependent code.

I want to reproduce your problem on my machine. Is it possible for you to make a zip archive which contains the whole of your “XXXXXt” project and share it? If you hesitate to make it too public, you can send it via 1-to-1 message to me.

How to send a 1-to-1 message? See the following screenshot:
31

Thank you for your reply! I’m sorry but we can not apply your request due to the security point of view. Our test project includes a lot of secret things and difficult to remove all of them…

Instead, I run your demo test (from VisualTestingInKatalonStudio) in virtual Windows, and make sure it works.
Well, so only my test has some problem.
But I can not provide my whole test, so I attached whole test log of “cleanMaterial” and “restorePreviousScreenshots.”

“cleanMaterial” has passed, but it include some error. I wish the log helps to investigate…
Please tell me if another information is required.

I also did :

  1. Run ./gradlew enableVisualTesting and get new files
  2. Check my keywords and driver folder and remove unnecessary file

restorePreviousScreenshots.log (28.3 KB)
creanmaterial.log (10.8 KB)

I also attach my test suites contents…
(I moved some your test case to another folder… is it related?)

“chronos_capture” includes following

Could you take a screenshot of the “Storage” folder in you project?

Is the Storage folder there at all?

Is there any files and sub-folders contained in the Storage folder?

If there are, please open the sub-folders so that I can see what’s there, take a screenshot and please share it.

These are screenshots of “Storage” folder (in Windows)
We also managed another files other than screenshots for visualtest here.

There are 4 sub folder

Expand chronos_capture

I have created a new version of jar Materials-0.73.3.jar.

1 . Please stop your KS
2. open /Drivers/ where you will find a jar named ‘VT-Materials-0.73.2.jar’. Please delete it.
3. Please download Materials-0.73.3.jar from the above-mentioned URL. Place the new jar into the Drivers folder.
4. Restart KS and run the test.

Your project will fail again, but hopefully with different message in the Console. I expect that the message will tell us which file/folder in the Storage folder caused the problem.

1 Like

NPE

I have a doubt on Storage\logos, Storage\strage.tmp, Storage\stv files. I am sure, the VisualTestingInKatalonStudio would never create them. I guess you, @rie.ohta, created them, right?

The Storage folder is meant to be used solely by the code of VisualTestingInKatalonStudio, adhoc files should not to be located there.

I wanted the Storage folder hidden, invisible for anyone other than me to avoid confusion; but it is impossible for me to make the folder hidden. I regret, the Storage folder is visible to you.

I think these unexpected files/folders make a class contained in the Materials-0.72.2.jar crazy and let it throw NPE. The class is too fragile, I agree with it. I need to make the Materials more robust.

Please move these files/folders out of the Storage folder to somewhere else. You can create any directory as you like.

1 Like

This was exactly the cause. I removed them and the test has passed!!
Sorry for my ignorance and thank you for your investigation!


Just to be sure, I attach the error logs with Materials-0.73.3.jar .

cleanMaterials.log (11.6 KB)
RestorePreviousScreenshots.log (29.0 KB)