cucumber / cucumber-android

Android support for Cucumber-JVM
MIT License
135 stars 62 forks source link

Can't generate report on Android API 34 #127

Closed fortmea closed 7 months ago

fortmea commented 8 months ago

👓 What did you see?

java.lang.IllegalArgumentException: Couldn't create parent directories of '/target/cucumber.json'. Make sure the the parent directory '/target' isn't a file. This happens with any given path, except "data/data/br.codans.cucumberex/target/report.json" though i can't see any new folder anywhere and there's no clear problem. It just runs and pass the tests

✅ What did you expect to see?

I expected that the report files would be correctly generated, as i've followed the correct instructions in setting the project up.

📦 Which tool/library version are you using?


    implementation("io.cucumber:cucumber-android:7.14.0")
    implementation("io.cucumber:cucumber-junit:7.14.0")
    testImplementation("junit:junit:4.12.2")
    androidTestImplementation("androidx.test:core:1.5.0")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
    androidTestImplementation("androidx.test:rules:1.5.0")
    androidTestImplementation("io.cucumber:cucumber-java8:6.8.1")

🔬 How could we reproduce it?

  1. Create an Android App, with basic single-activity interface with just an editText;
  2. Create Runner:
    
    import io.cucumber.junit.Cucumber
    import io.cucumber.junit.CucumberOptions
    import org.junit.runner.RunWith
    @RunWith(Cucumber::class)
    @CucumberOptions(
    glue = ["br.codans.cucumberex.test.steps"],
    features = ["features"],
    plugin = ["json:data/data/br.codans.cucumberex/target/report.json"],

) class ExemploCucumber{ }

3. add steps and features:

class ExemploInserirTexto {

private val field = R.id.editTextText

@Dado("que o app iniciou")
fun dadoQueOSistemaEstaInicializado() {
    ActivityScenario.launch(MainActivity::class.java)

}

@Quando("o usuário digita {string}")
fun quandoOUsuarioRealizaUmaAcaoComTexto(texto: String) {
    Espresso.onView(ViewMatchers.withId(field)).perform(ViewActions.clearText())
    Espresso.onView(ViewMatchers.withId(field)).perform(ViewActions.replaceText(texto))

}

@Então("o editText deve exibir {string}")
fun entaoOResultadoDeveSerConformeEsperado(texto: String) {
    Espresso.onView(ViewMatchers.withId(field)).check(ViewAssertions.matches(ViewMatchers.withText(texto)))

}

}

language: pt

Funcionalidade: Exemplo de como passar texto

Cenário: Passar texto para um step Como usuário Desejo escrever um texto no campo Para que esse texto possa ser usado no app

Delineacao do Cenario: Digitar no campo Dado que o app iniciou Quando o usuário digita Então o editText deve exibir Exemplos: | Texto a ser digitado | | "olá" | | "Como vai?" | | "12345" | | "Texto de exemplo" |


5. Run

![Error. it's shown in every case, except when the path provided in the first section](https://github.com/cucumber/cucumber-android/assets/33238565/c04e2268-e0b0-4c58-9f67-91c12da3f1e9)

### 📚 Any additional context?

Sorry if there's not enough info. If needed, i can share the project files.

----
fortmea commented 8 months ago

I possibly have failed to undestand the example project, as it somehow generates report files without asking for any of it. Also, it's lacking some files

fortmea commented 7 months ago

Managed to get it working. Had to inform my custom runner in gradle and then create report folder manually. Now i face another issue with html reports: TypeError: Failed to construct 'URL': Invalid URL at t.default (html.html:47:117256)

lsuski commented 7 months ago

As stated in readme - html reports may nit work due to missing api on Android. Also from what I see you have strange dependencies setup and you use RunWith annotation which is not needed at all and can break something

fortmea commented 7 months ago

Sorry, i was testing to see if it was some problem with the dependencies' versions. Anyways, for now i'll be using a tool to convert json reports to HTML. Thanks for your answer.