First of, not really an ordinary "how to resolve null pointer exception?". My problem is when I use mvn test -Dtest=ClassThatIAmTestingTest , it will say nullPointerException on the line number of the Test Class but it doesnt say where or what line in my ClassThatIAmTesting.java that caused the NullPointerException. Is there a setting in mvn where I can get the "caused by " ? I can just manually insert a try-catch line per line but I refuse to believe this is the best way. This is java 8 btw.
Sample code:
1ClassThatIAmTesting {
2
3 public String doSomething() { ... }
999
1000}
1ClassThatIAmTestingTest {
2
3 public void testSomething() {
4
5 ClassThatIAmTesting classThatIAmTesting = new ClassThatIAmTesting();
6 String s = classThatIAmTesting.doSomething();
7
8}
maven only shows: java.lang.NullPointerException at com.blah.blah.blah.ClassThatIAmTestingTest.testSomething(ClassThatIAmTestingTest.6)
I tried mvn test -Dtest=ClassThatIAmTestingTest -e hoping the -e will tell me where or what line in the code that I have failed to initialize.
I also tried going inside the surefire folder inside the target folder of my project. It also did not say where exactly in the code that made the nullpointerexception
On the suggested stackoverflow questions/topics listed, there were no topics where finding out the exact line of code where the nullpointerexception exists exists. I did not find topics with regards to surefire settings as well where I can set this up.
EDIT: My question was flagged as duplicate however the pasted/suggested duplicate topic still doesn't really answer the question. I'm not looking for solution on how to solve a nullPointerException. My question is where is it exactly on the class being tested because the stacktrace is ambiguous. With this, I suppose it's just a matter of wrapping parts of my code in try-catch and hopefully find where it is exactly.