Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video isn't recorded if testName contains special characters and test which is actually Passed, marked as Failed in the test run #675

Open
zakaz opened this issue Sep 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@zakaz
Copy link

zakaz commented Sep 23, 2024

Describe the bug
In 1.5.4 Kaspresso, with withForcedAllureSupport(), if testName contains one of these symbols: : , " , *, ?, <, >, | , / then the Runner can't create a file in Android emulator.
It throws java.io.IOException: Operation not permitted exception while trying to execute method .createFileIfNeeded() from this block com.kaspersky.kaspresso.files.resources.impl.DefaultResourceFilesProvider:

override fun provideVideoFile(tag: String, subDir: String?): File {
        val resFileName: String = resourceFileNamesProvider.getFileName(
            tag,
            FileExtension.MP4.toString()
        )

        return resourcesDirsProvider.provide(resourcesRootDirsProvider.videoRootDir, subDir)
            .resolve(resFileName)
            .createFileIfNeeded()
    }

Even though, the test itself is Passed, in after section it can't stop the video recording, it shows error Can't stop video recording as it was not started

To Reproduce
Steps to reproduce the behavior:
To reproduce the issue, you can run the test from Kaspresso framework, from com.kaspersky.kaspresso.alluresupport.sample.AllureSupportTest class.

  1. For the test counter() add testName with any of the symbols, for example: "123: 123"
  2. Execute the test
  3. You'll see in the Logcat that the test was PASSED, but due to java.io.IOException: Operation not permitted it was marked as FAILED in the test run
  4. remove : symbol from the testName,
  5. Execute the test
  6. The test is PASSED, and in the test run it also was marked as PASSED

Expected behavior
It's expected that the symbols in the testName doesn't affect to the status of the test in the test run

Desktop:

  • OS: Apple M1 Pro MacOs: 14.5
  • Android Studio Koala Feature Drop | 2024.1.2
  • Kaspresso 1.5.4

Android emulator:

  • Device: Pixel 6a API 33
  • Image: system-images/android-33/google_apis_playstore/arm64-v8a/

Additional context

@zakaz zakaz added the bug Something isn't working label Sep 23, 2024
@zakaz
Copy link
Author

zakaz commented Sep 23, 2024

logcat_com_kaspersky_kaspresso_alluresupport_sample_AllureSupportTest.txt

@zakaz
Copy link
Author

zakaz commented Sep 23, 2024

Possible solution:
in com.kaspersky.components.alluresupport.interceptors.testrun.HackyVideoRecordingTestInterceptor class
in onTestStarted() method
replace with:

val videoName = testInfo.testName.replace("/|:|\"|\\*|\\?|<|>|\\|".toRegex(), "_")
videos.record("Video_${videoName}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant