Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Added extra validation to undefined type #25

Closed
wants to merge 4 commits into from

Conversation

wallysson-hotmart
Copy link

@wallysson-hotmart wallysson-hotmart commented Dec 30, 2016

At some cases, while generating xml reports the allure common can't get correctly the value from start and stop. In that cases they pass values as empty string making allure report generation to fail causing errors like:

Exception in thread "main" java.lang.NumberFormatException: For input string: ""
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Long.parseLong(Long.java:601)
    at java.lang.Long.valueOf(Long.java:803)
    at com.sun.xml.internal.bind.DatatypeConverterImpl._parseLong(DatatypeConverterImpl.java:118)
    at ru.yandex.qatools.allure.model.TestCaseResult_JaxbXducedAccessor_stop.parse(TransducedAccessor_field_Long.java:50)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StructureLoader.startElement(StructureLoader.java:195)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:559)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:538)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:153)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:380)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2787)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:243)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:221)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:276)
    at javax.xml.bind.JAXB.unmarshal(JAXB.java:242)
    at ru.yandex.qatools.allure.commons.AllureFileUtils.unmarshal(AllureFileUtils.java:59)
    at ru.yandex.qatools.allure.commons.AllureFileUtils.unmarshal(AllureFileUtils.java:50)
    at ru.yandex.qatools.allure.commons.AllureFileUtils.unmarshal(AllureFileUtils.java:40)
    at ru.yandex.qatools.allure.data.io.TestSuiteReader$TestSuiteResultIterator.next(TestSuiteReader.java:48)
    at ru.yandex.qatools.allure.data.io.TestSuiteReader$TestSuiteResultIterator.next(TestSuiteReader.java:1)
    at ru.yandex.qatools.allure.data.io.TestCaseReader$TestCaseResultIterator.nextSuite(TestCaseReader.java:46)
    at ru.yandex.qatools.allure.data.io.TestCaseReader$TestCaseResultIterator.hasNext(TestCaseReader.java:56)
    at ru.yandex.qatools.allure.data.AllureReportGenerator.generate(AllureReportGenerator.java:61)
    at ru.yandex.qatools.allure.data.AllureReportGenerator.generate(AllureReportGenerator.java:53)
    at ru.yandex.qatools.allure.AllureMain.main(AllureMain.java:48)
Command aborted due to exception {}.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:153)
    at ru.yandex.qatools.allure.command.ReportGenerate.runUnsafe(ReportGenerate.java:48)
    at ru.yandex.qatools.allure.command.AbstractCommand.run(AbstractCommand.java:52)
    at ru.yandex.qatools.allure.CommandLine.main(CommandLine.java:46)

To fix that, i've created some variables to handle data before it generates the actual XML data.
Some issues already related to this at other projects:

webdriverio/webdriverio#1432
webdriverio-boneyard/wdio-allure-reporter#26

I'm not shure if the beans folder it's the best place to fix the actual problem, but at some cases where the event it's waiting for an execution to be finishe like "waitForExist" from webdriver causes to pass undefined data while generating de XML.

@just-boris
Copy link
Contributor

This fix was already proposed in #23, but it will not work.

I tried to explain this here in the comment that the whole integration Cucumber -> Webdriver.io -> Allure is broken. Webdriver.io tries to mitigate the differences between testing frameworks, such as Mocha, Jasmine, and Cucumber, and sometimes abstractions there are leaking, that causes problems.

This repo also contains some common layer between testing frameworks and Allure reporting core. But the thing is that this core is quite stable and successfully used by some other tools:

They all are working fine without fix like this one. I am not sure that your changes will not be breaking there. This is why I'd rather recommend focusing any possible efforts directly to Webdriver.io ecosystem. Check out webdriverio-boneyard/wdio-cucumber-framework#34 as another possible solution for your issue.

@wallysson-hotmart
Copy link
Author

I'm agree with you that some projects that are actually working could not run properly due to changes, even few ones like this PR. In my case, some calls at .toXML was getting undefined values which was preventing Allure generate correctly. I will try to find a way into wdio-allure-reporter.

The best clue untill now to fix this is this issue you related: webdriverio-boneyard/wdio-cucumber-framework#34

Actually im my project it's fixed as i'm forked the repo, i will continue using it with my fixes but i will try to find a way to fix it by the wdio-allure-reporter. Thanks by the way

@just-boris
Copy link
Contributor

just-boris commented Apr 29, 2017

Hello!

Finally, there is a solution for that problem. I have merged #26 that handles stop times differently. Now empty strings are just do not appear in the resulting XML.

It will be working only with Allure v2 (in v1 you still will be seeing some error), that you can try as a beta now npm install allure-commandline@beta. As a beta version, it doesn't not ship Jenkins plugin yet, only CLI at this moment.

@just-boris just-boris closed this Apr 29, 2017
link89 pushed a commit to link89/allure-js-commons that referenced this pull request Jul 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants