shivadorepally / junitparams

Automatically exported from code.google.com/p/junitparams
0 stars 0 forks source link

JUnitParams tests fail with java.lang.NullPointerException on windows environments #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Checkout junitparams on windows
2. Run maven test task

What is the expected output? What do you see instead?
Expected output:
All tests pass or are skipped/ignored.

Actual output:
Tests
 - ParametersForMethodTest
 - ParamsInAnnotationTest
fail with:
java.lang.NullPointerException
    at junitparams.internal.ParameterisedTestMethodRunner.findChildForParams(ParameterisedTestMethodRunner.java:60)
    at junitparams.internal.ParameterisedTestMethodRunner.runTestMethod(ParameterisedTestMethodRunner.java:39)
    at junitparams.internal.ParameterisedTestClassRunner.runParameterisedTest(ParameterisedTestClassRunner.java:143)
    at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:405)
    at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:383)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

What version of the product are you using? On what operating system?
Windows XP Sp3

Please provide any additional information below.
This bug is connected to fix applied in 
http://code.google.com/p/junitparams/issues/detail?id=41.

The fix applied uses system's newline property which is wrong for at least two 
reasons:
- the tests of junitparams fail under windows environment
- the tests of library users will fail under certain conditions (see attached 
issue link) on Windows environment but succeed on system using different 
newline character.

I attach diff with fix, that allows these thests to pass on Windows. Rationale 
for this fix is that we actually escape test input provided by user 
(developer), library should handle it correctly on any platform.

Please review this patch, and apply it if you think it's correct.

Original issue reported on code.google.com by jankowsk...@gmail.com on 9 Jul 2013 at 3:07

Attachments:

GoogleCodeExporter commented 8 years ago
Any chance to apply this patch?

Original comment by pjagi...@gmail.com on 24 Oct 2013 at 1:39

GoogleCodeExporter commented 8 years ago
I vote for releasing this patch, too.

This issued cause me some grief when writing my own test using junitparams to 
supply "Parameterising tests via values in annotation".

Environment:
JUnitParams 1.0.2 on Windows 7, 64-bit, using JUnit 4.11, Ant 1.9.2, and JDK 
7u45.

:
:
runtest:
    [junit] Running FakeAuctionServerTests
    [junit] Testsuite: FakeAuctionServerTests
    [junit] Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.2 sec
    [junit] Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.2 sec
    [junit]
    [junit] Testcase: [0] AAA,1 (params_in_annotation) took 0.02 sec
    [junit] Testcase: [1] BBB,2 (params_in_annotation) took 0 sec
    [junit] Testcase: getSniperCommandFromMessage_withCmdJOIN_returnsJOIN took 0.08 sec
    [junit] Testcase: getSniperCommandFromMessage_withCmdBID_returnsBID took 0 sec
    [junit] Testcase: [0] AAA (getSniperCommandFromMessage_calledWithACmd_returnsThatCmd) took 0 sec
    [junit]     Caused an ERROR
    [junit] null
    [junit] java.lang.NullPointerException
    [junit]     at java.lang.String.length(String.java:623)
    [junit]     at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:414)
    [junit]     at java.lang.StringBuilder.append(StringBuilder.java:132)
    [junit]     at junitparams.internal.InvokeParameterisedMethod.evaluate(InvokeParameterisedMethod.java:184)
    [junit]     at junitparams.internal.ParameterisedTestMethodRunner.runMethodInvoker(ParameterisedTestMethodRunner.java:48)
    [junit]     at junitparams.internal.ParameterisedTestMethodRunner.runTestMethod(ParameterisedTestMethodRunner.java:42)
    [junit]     at junitparams.internal.ParameterisedTestClassRunner.runParameterisedTest(ParameterisedTestClassRunner.java:143)
    [junit]     at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:405)
    [junit]     at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:383)
    [junit]
    [junit] Test FakeAuctionServerTests FAILED
:
:

Original comment by openmi...@gmail.com on 25 Oct 2013 at 2:52

GoogleCodeExporter commented 8 years ago
After figuring out how to use Mercurial to get the source code, I built the 
JUnitParams jar with your patch applied. 

JUnitParams 1.0.3-SNAPSHOT on Windows 7, 64-bit, using JUnit 4.11, Maven 3.0.4, 
and JDK 7u45.

mvn package

First, I built it straight as it came from hg: RESULT ...
:
Tests run: 117, Failures: 0, Errors: 2, Skipped: 5
:
[INFO] BUILD FAILURE
:

Second, I applied your patch and re-built it: RESULT ...
:
Tests run: 124, Failures: 0, Errors: 0, Skipped: 5

[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ JUnitParams ---
[INFO] Building jar: 
c:\dev\hg_clones\junitparams\target\JUnitParams-1.0.3-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.517s
[INFO] Finished at: Fri Oct 25 21:01:46 EDT 2013
[INFO] Final Memory: 12M/246M
[INFO] ------------------------------------------------------------------------

However I got the same Null PointerException (as shown in my previous comment) 
when I replaced JUnitParams-1.0.2.jar with the JUnitParams-1.0.3-SNAPSHOT.jar 
that I just build.

Original comment by openmi...@gmail.com on 26 Oct 2013 at 1:07

GoogleCodeExporter commented 8 years ago

Original comment by lipinski...@gmail.com on 26 Oct 2013 at 4:09

GoogleCodeExporter commented 8 years ago
I think NullPointer error provided by openmi...@gmail.com in comments is 
different issue (look at backtrace - different origin of exception). Maybe it 
would be good to open another issue with some sample test code to reproduce the 
problem.

Original comment by jankowsk...@gmail.com on 26 Oct 2013 at 4:32

GoogleCodeExporter commented 8 years ago
Patch applied. Will be in 1.0.3, to be released most probably on monday.
@openmic62: create a new issue WITH TEST CODE please, if you want it fixed.

Original comment by lipinski...@gmail.com on 26 Oct 2013 at 5:12

GoogleCodeExporter commented 8 years ago
@lipinski I want to understand clearly. First, @jankowski thinks my the issue 
I'm seeing differs from the one addressed in this record (that is, records 46, 
41). Second, you want me to create a new record in which I report my issue: how 
to reproduce, expected output, actual output, env, etc.

If the 2nd is true, then that is very cool since it would be my first time 
contributing to an opensource project :-). As such, please bear with me if I 
fumble about a bit. I welcome any guidance you can provide.

I have been investigating since my last post. A thought occurred to me that the 
issue I'm seeing might be a problem related to my use of Ant when building. To 
enable experiments, I spent time yesterday getting my build working in Maven. 
With that done, I'm now working to clean things up ... then do experiments to 
see what is the root cause.

Thanks for your help.

Original comment by openmi...@gmail.com on 27 Oct 2013 at 2:44

GoogleCodeExporter commented 8 years ago
Hello,
I still get a NullPointerException using junitparams 1.0.2 on windows. Could 
you tell me when you plan to release version 1.0.3 (including the bugfix)? We 
could not use SNAPSHOT-Versions in our releases.

Many regards,
Hermann 

java.lang.NullPointerException: null
    at junitparams.internal.ParameterisedTestMethodRunner.findChildForParams(ParameterisedTestMethodRunner.java:60)
    at junitparams.internal.ParameterisedTestMethodRunner.runTestMethod(ParameterisedTestMethodRunner.java:39)
    at junitparams.internal.ParameterisedTestClassRunner.runParameterisedTest(ParameterisedTestClassRunner.java:143)
    at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:405)
    at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:383)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

Original comment by hba...@gmail.com on 26 May 2014 at 6:50