Skip to content

Conversation

@jkttt
Copy link
Contributor

@jkttt jkttt commented Aug 15, 2017

When test is placed in default package, allure fails testrun with NullPointerException

java.lang.NullPointerException at io.qameta.allure.junit4.AllureJunit4.getPackage(AllureJunit4.java:236) at io.qameta.allure.junit4.AllureJunit4.createTestResult(AllureJunit4.java:254) at io.qameta.allure.junit4.AllureJunit4.testStarted(AllureJunit4.java:83) at

Added null pointer processing and empty package name for that case

P.s.
I havent provided tests for that case, because default package class can not be imported, and therefore can not be run from test.

Checklist


private String getPackage(final Class<?> testClass) {
return testClass.getPackage().getName();
if (testClass.getPackage() != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional.of(testClass)
    .map(::getPackage())
    .map(::getName())
    .orElse("");

Copy link
Member

@baev baev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add unit test for a such case?

@jkttt
Copy link
Contributor Author

jkttt commented Aug 15, 2017

Ок

@baev baev merged commit 197d547 into allure-framework:master Aug 16, 2017
@baev
Copy link
Member

baev commented Aug 16, 2017

@jkttt thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants