The core module's internals use static functions in TestNameDetector to determine the name of the current test class and test. These functions parse the stacktrace of the current thread to determine these values.
This works fine if you take screenshots from the test thread, but not so well when running them from another thread. Since UI interactions with ActivityScenario occur on the main thread, this is a problem. See Karumi/Shot#135 for more information.
If it's possible to somehow find the test name from the main thread, I suggest that TestNameDetector be updated to do that. But I don't think this is possible. In that case, I would propose the following API additions:
An interface TestNameProvider with abstract getTestClass and getTestName methods
A way to plug in any custom implementation of TestNameProvider for this library to use internally.
The default TestNameProvider implementation could pass through to TestNameDetector so that the default behavior does not change. But any consumer who needs to can instead provide an explicit name for their test.
The
core
module's internals use static functions inTestNameDetector
to determine the name of the current test class and test. These functions parse the stacktrace of the current thread to determine these values.This works fine if you take screenshots from the test thread, but not so well when running them from another thread. Since UI interactions with ActivityScenario occur on the main thread, this is a problem. See Karumi/Shot#135 for more information.
If it's possible to somehow find the test name from the main thread, I suggest that TestNameDetector be updated to do that. But I don't think this is possible. In that case, I would propose the following API additions:
TestNameProvider
with abstractgetTestClass
andgetTestName
methodsTestNameProvider
for this library to use internally.The default
TestNameProvider
implementation could pass through toTestNameDetector
so that the default behavior does not change. But any consumer who needs to can instead provide an explicit name for their test.