composer icon indicating copy to clipboard operation
composer copied to clipboard

Fix NPE when listing files in screenshot folder

Open rafakob opened this issue 8 years ago • 1 comments

listFiles() may return null which leads to crash:

Exception in thread "main" java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.collections.ArraysKt___ArraysKt.toList, parameter $receiver
        at kotlin.collections.ArraysKt___ArraysKt.toList(_Arrays.kt)
        at com.gojuno.composer.TestRunKt$pullTestFiles$3.call(TestRun.kt:177)
        at com.gojuno.composer.TestRunKt$pullTestFiles$3.call(TestRun.kt)

rafakob avatar Feb 09 '18 11:02 rafakob

How to reproduce this NPE?

it.listFiles() can return null only when it is file instead of folder. Who is creating it as a file?

Composer code doesn't seem to be touching it, creating parent testClassName folder only. So it looks like file was downloaded by adb pull. Which could happen only when not complying to spoon screenshot contract

storage/sdcard/app_spoon-screenshots/package.testClassName/testMethodName/screenshotName.png`

In this case, I think proposed solution to silently ignoring NPE is incorrect. Because storage/sdcard/app_spoon-screenshots/package.testClassName/testMethodName screenshot is not getting merged into html report. Instead, I would prefer to have an assertion message to avoid debugging why.

plastiv avatar Mar 18 '19 14:03 plastiv