In net.thucydides.core.reports.junit.JUnitXMLConverter timestamp format is wrong causing to throw "java.time.DateTimeException: Field DayOfYear cannot be printed as the value 100 exceeds the maximum print width of 2 " .
Correct format should be YYYY-MM-dd hh:mm:ss
Hey, I am also facing the same problem.
Changing DD to dd will fix the issue, however please note that YYYY should also be adjusted to yyyy as having it in capitals may cause issues around the new year boundary.
Correct format should be: yyyy-MM-dd hh:mm:ss
The same problem, keep in mind today is 100th day of the year.
Please, add the fix to the maven repo ASAP
Hi,
I hope that John will release a new version of Serenity containing the fix as soon as possible but if you cannot wait you might want to use the following workaround to mitigate the problem in the meantime.
The basic idea behind the workaround is to overcome the problem by using Reflection and a custom CucumberWithSerenity test runner (I'm using it mainly to add additional functionality like ensuring that feature and scenario names are unique).
`
public class CustomCucumberWithSerenity extends CucumberWithSerenity {
/**
* Workaround for Serenity Bug #1195: java.time.DateTimeException: Field DayOfYear cannot be printed as the value 100 exceeds the maximum print width of 2
*
* Remove this as soon as a released version containing the fix is available. (FIXME)
*
* For more details see:
* - https://github.com/serenity-bdd/serenity-core/issues/1195
*/
static {
try {
Field timestampFormat = JUnitXMLConverter.class.getDeclaredField("TIMESTAMP_FORMAT");
timestampFormat.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(timestampFormat, timestampFormat.getModifiers() & ~Modifier.FINAL);
timestampFormat.set(null, DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
} catch (Exception e) {
e.printStackTrace();
}
}
public CustomCucumberWithSerenity(final Class<?> clazz) throws InitializationError, IOException {
super(clazz);
// verifyThatFeatureAndScenarioNamesAreUnique();
}
`
And of course you have to replace "@RunWith(CucumberWithSerenity.class)" with "@RunWith(CustomCucumberWithSerenity.class)" on your test runner class(es).
HTH,
Wolfgang
I'm facing the same problem:
java.time.DateTimeException: Field DayOfYear cannot be printed as the value 100 exceeds the maximum print width of 2
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
Downgraded serenity to 1.8.4 and now it works properly.
Fixed in 1.9.6 thanks to a Pull Request from @mayuraviraj
When will this release be pushed to maven repository?
It is already in bintray and what been synced, but it can take up to 24 hours to see it on central
@datentyp Thank you so much I was stuck on this issue for more than a day and I am using cucumber-starter version so was not able to use fix of core. Your code piece solved my issue
Thanks all~
Most helpful comment
Hi,
I hope that John will release a new version of Serenity containing the fix as soon as possible but if you cannot wait you might want to use the following workaround to mitigate the problem in the meantime.
The basic idea behind the workaround is to overcome the problem by using Reflection and a custom CucumberWithSerenity test runner (I'm using it mainly to add additional functionality like ensuring that feature and scenario names are unique).
`
public class CustomCucumberWithSerenity extends CucumberWithSerenity {
`
And of course you have to replace "@RunWith(CucumberWithSerenity.class)" with "@RunWith(CustomCucumberWithSerenity.class)" on your test runner class(es).
HTH,
Wolfgang