Closed josousa82 closed 2 years ago
I'm sorry for raising this issue, I saw the repo after, that already have a fix to this. I will apply locally.
String earlyAccess = "-ea"; if (version.endsWith(earlyAccess)) { version = version.substring(0, version.length() - earlyAccess.length()); }
I will also change my version from early access.
Hi there. This library is used in courses from JetBrains academy. I tried to use IntelliJ to run the tests, although I couldn't make it work. The error was always when starting the test suite. I use java Zulu since that's what is used in the company where I work, and it happened that the version of the JDK has some chars in the name.
So I spend some time debugging, starting with the Gradle tasks and going through the implementation of the tests, to be able to find the issue.
This should be fairly simple to fix, although I haven't pulled the library, although if there's the need to fix it, let me know, I'm happy to contribute.
I added a screenshot of what I would consider a bug in the method with the signature
public static int getJavaVersion()
in the packagepackage org.hyperskill.hstest.common;
.The error is with the parseInt method because the conditional above is only checking for a java version number that has a dot, and before passing the string to be parsed the integer, there are no checks, ensuring the string is actually a number.
` /**
@return Java version as integer. */ public static int getJavaVersion() { String version = System.getProperty("java.version"); // "17-ea"
}`
Part of the stack trace below with Gradle report image:
`java.lang.AssertionError: Error during testing
Cannot parse Integer from the output part "17-ea"
java.lang.NumberFormatException: For input string: "17-ea" at org.junit.Assert.fail(Assert.java:88) at org.hyperskill.hstest.stage.StageTest.start(StageTest.java:155) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)`