question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataProvider cannot be used with null values anymore

See original GitHub issue

TestNG Version

7.4.0 (still worked with 7.3.0)

Expected behavior

A @DataProvider can be used to provided null values for any of the test method’s arguments.

Actual behavior

If the data contains any null value and log level is > 1, TestNG fails after successfully running the current test, aborting the whole suite:

java.lang.NullPointerException
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:550)
	at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
	at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:517)
	at org.testng.internal.Utils.extractParameterTypes(Utils.java:612)
	at org.testng.reporters.TextReporter.logResult(TextReporter.java:140)
	at org.testng.reporters.TextReporter.logResults(TextReporter.java:74)
	at org.testng.reporters.TextReporter.onFinish(TextReporter.java:34)
	at org.testng.TestRunner.fireEvent(TestRunner.java:923)
	at org.testng.TestRunner.afterRun(TestRunner.java:887)
	at org.testng.TestRunner.run(TestRunner.java:599)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
	at org.testng.SuiteRunner.run(SuiteRunner.java:276)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
	at org.testng.TestNG.runSuites(TestNG.java:1063)
	at org.testng.TestNG.run(TestNG.java:1031)
	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Is the issue reproductible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

   @DataProvider( name = "name" )
   public Object[][] dp() {
      return new Object[][] { new Object[] { null } };
   }

   @Test( dataProvider = "name" )
   public void test( String arg ) {
   }

Unbenannt

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ickzoncommented, Jun 1, 2021

With testng-7.5.0-20210528.084226-28.jar I do no longer get this error. Thanks a lot!

0reactions
krmahadevancommented, May 31, 2021

@ickzon - It looks like this is no longer a problem in TestNG 7.5.0 (next upcoming release).

Please try using 7.5.0-SNAPSHOT

https://oss.sonatype.org/content/repositories/snapshots/org/testng/testng/7.5.0-SNAPSHOT/

Refere here for info on how to consume a snapshot dependency.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to provide null data in dataprovider in Testng
Hii Bipin, solved my issue...i did send my value as null but used a condition based upon the error message that pops up,...
Read more >
MySQL: Data is Null. This method or property cannot be called ...
This method or property cannot be called on Null values. #800 ... It's now running against tables; doesn't use views anymore.
Read more >
How To Use DataProviders In TestNG [With Examples]
DataProvider in TestNG is used to inject multiple values into the same test case, this guide explains how to use them in your...
Read more >
TestNG Tutorials 65 - DataProvider in TestNG
Below test method is not accepting any arguments while it has DataProvider. // You will get Data Provider mismatch exception.
Read more >
Assigning Null Value to a Variable - MSDN - Microsoft
It cannot hold any other type than integers. If you want to insert NULL to the database, you can certainly assign DBNull.Value as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found