cucumber / cucumber/cucumber-android

junit plugin requires 16 years old dependency

Open
#134 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
146
Forks
60
Avg merge
5d 22h
Merged PRs (30d)
1

Description

### 🤔 What's the problem you've observed?

During compilation I faced R8 error that javax.xml.stream.* are missing:

```
ERROR: R8: Missing class javax.xml.stream.XMLOutputFactory (referenced from: void io.cucumber.junitxmlformatter.XmlReportWriter.writeXmlReport(java.io.Writer))
Missing class javax.xml.stream.XMLStreamWriter (referenced from: javax.xml.stream.XMLStreamWriter io.cucumber.junitxmlformatter.EscapingXmlStreamWriter.writer and 12 other contexts)
```
If I suppress the error with
```
-dontwarn javax.xml.stream.XMLOutputFactory
-dontwarn javax.xml.stream.XMLStreamWriter
```
I see runtime error

```
[2024-07-15T13:10:52.712+00:00Z] There was 1 failure:
[2024-07-15T13:10:52.712+00:00Z] 1) io.cucumber.android.CucumberJUnitRunnerBuilder
[2024-07-15T13:10:52.712+00:00Z] java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLOutputFactory;
[2024-07-15T13:10:52.712+00:00Z] at io.cucumber.junitxmlformatter.XmlReportWriter.writeXmlReport(XmlReportWriter.java:30)
[2024-07-15T13:10:52.712+00:00Z] at io.cucumber.junitxmlformatter.MessagesToJunitXmlWriter.close(MessagesToJunitXmlWriter.java:60)
[2024-07-15T13:10:52.712+00:00Z] at io.cucumber.core.plugin.JUnitFormatter.write(JUnitFormatter.java:35)
[2024-07-15T13:10:52.712+00:00Z] at io.cucumber.core.plugin.JUnitFormatter.$r8$lambda$lIOZf2g96s60oX1b0tjdfI5LY_s(Unknown Source:0)
...
```
This is because Android is missing many things from javax.

Looking through SO I found a workaround to add 16 years old library:
```
androidTestImplementation "javax.xml.stream:stax-api:1.0-2"
```
which help a little bit, but still the new error:
```
[2024-07-15T15:43:39.219+00:00Z] INSTRUMENTATION_STATUS: stack=javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase not found
[2024-07-15T15:43:39.219+00:00Z] at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
[2024-07-15T15:43:39.219+00:00Z] at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
[2024-07-15T15:43:39.219+00:00Z] at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
[2024-07-15T15:43:39.219+00:00Z] at javax.xml.stream.XMLOutputFactory.newInstance(XMLOutputFactory.java:98)
[2024-07-15T15:43:39.219+00:00Z] at io.cucumber.junitxmlformatter.XmlReportWriter.writeXmlReport(XmlReportWriter.java:30)
[2024-07-15T15:43:39.219+00:00Z] at io.cucumber.junitxmlformatter.MessagesToJunitXmlWriter.close(MessagesToJunitXmlWriter.java:60)
[2024-07-15T15:43:39.219+00:00Z] at io.cucumber.core.plugin.JUnitFormatter.write(JUnitFormatter.java:35)
...
```
To. fix this one need to add additional dependency:
```
androidTestImplementation 'com.fasterxml:aalto-xml:1.2.2'
```

### ✨ Do you have a proposal for making it better?

At least document this case to save time for others.
The best would be to implement missing classes in cucumber-android to use Android's possibilities https://developer.android.com/reference/javax/xml/parsers/package-summary

### 📚 Any additional context?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.