allure-framework / allure-kotlin

Allure integrations for test frameworks targeting Kotlin and Java with 1.6 source compatibility.
Apache License 2.0
57 stars 21 forks source link

Allure Android Sample #22

Closed viclovsky closed 4 years ago

viclovsky commented 4 years ago

Hi, @kamildziadek

I have found two problems in new release on testing it.

  1. Tests from samples is called but it shouldn’t be. Samples tests break a build.
  2. And the most important one. I have run instrumental tests and haven’t found a result in the target folder (sdcard/allure-results). I have run it on Nexus 5X API 27 emulator. Moreover I have found the error on using the rules (like SampleActivityFailureTest) :
io.qameta.allure.kotlin.AllureResultsWriteException: Could not write Allure attachment
at io.qameta.allure.kotlin.FileSystemResultsWriter.write(FileSystemResultsWriter.kt:49)
at io.qameta.allure.kotlin.AllureLifecycle.writeAttachment(AllureLifecycle.kt:497)
at io.qameta.allure.kotlin.AllureLifecycle.addAttachment(AllureLifecycle.kt:453)
at io.qameta.allure.kotlin.AllureLifecycle.addAttachment(AllureLifecycle.kt:436)
at io.qameta.allure.kotlin.Allure.attachment(Allure.kt:237)
at io.qameta.allure.android.rules.LogcatRule.dump(LogcatRule.kt:43)
at io.qameta.allure.android.rules.LogcatRule.access$dump(LogcatRule.kt:17)
at io.qameta.allure.android.rules.LogcatRule$apply$1.evaluate(LogcatRule.kt:25)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:104)
at io.qameta.allure.android.runners.AllureAndroidJUnit4.run(AllureAndroidJUnitRunners.kt:28)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
at io.qameta.allure.android.runners.AllureAndroidJUnitRunner.onStart(AllureAndroidJUnitRunners.kt:82)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2075)
Caused by: java.io.FileNotFoundException: /storage/emulated/0/allure-results/896ff2ef-b3f2-47b6-a560-15134a011c65-attachment.txt (Permission denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:287)
at java.io.FileOutputStream.<init>(FileOutputStream.java:223)
at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
at io.qameta.allure.kotlin.FileSystemResultsWriter.write(FileSystemResultsWriter.kt:44)
... 33 more

If I don’t use the rule, the error dissapiares, but the result folder is still empty.    

I am working on 2nd issue but maybe you have any idea of possible root cause

kamildziadek commented 4 years ago

Hey @viclovsky,

Tests from samples is called but it shouldn’t be. Samples tests break a build.

Samples shouldn't be part of the build pipeline. They are just there to show how does the library work, we shouldn't rely on them passing as an indicator of a valid build

And the most important one. I have run instrumental tests and haven’t found a result in the target folder (sdcard/allure-results). I have run it on Nexus 5X API 27 emulator. Moreover I have found the error on using the rules (like SampleActivityFailureTest)

I screwed up the way permissions are automatically requested in the runners. Fix is coming in a couple of minutes.