Skip to content

[🐛 Bug]: Error when filtering tests #14411

@therealbrad

Description

@therealbrad

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

22 LTS

Mode

WDIO Testrunner

Which capabilities are you using?

What happened?

I filter test executions using mocha-opts.grep which leaves me with a lot of (expected) sessions with no tests and empty junit xml files. Before 00e3e2f those files looked like this:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="0" failures="0" errors="0" skipped="0"/>

But now they look like this:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="1" errors="0" skipped="0">
  <testcase>
    <failure message="No tests found"/>
  </testcase>
</testsuites>

The JUnit Reporter plugin for Jenkins throws this error on the new files:

ERROR: Step 'Publish JUnit test result report' aborted due to exception: 
java.lang.NullPointerException
	at PluginClassLoader for junit//hudson.tasks.junit.CaseResult.<init>(CaseResult.java:211)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.<init>(SuiteResult.java:487)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.parseSuite(SuiteResult.java:401)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:369)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:604)
Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to Real Device
		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1923)
		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:384)
		at hudson.remoting.Channel.call(Channel.java:1112)
		at hudson.FilePath.act(FilePath.java:1228)
		at hudson.FilePath.act(FilePath.java:1217)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitParser.parseResult(JUnitParser.java:146)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.parse(JUnitResultArchiver.java:177)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.parseAndSummarize(JUnitResultArchiver.java:282)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:194)
		at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
		at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
		at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
		at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:818)
		at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:767)
		at hudson.model.Build$BuildExecution.post2(Build.java:179)
		at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:711)
		at hudson.model.Run.execute(Run.java:1854)
		at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
		at hudson.model.ResourceController.execute(ResourceController.java:101)
		at hudson.model.Executor.run(Executor.java:445)
Caused: java.io.IOException: Failed to read /home/bdermanouelian/jenkins_home/workspace/iOS UI Performance/src/ios/reports/results-undefined-undefined-0-0.xml
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:615)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parsePossiblyEmpty(TestResult.java:518)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:454)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:436)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:413)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.<init>(TestResult.java:259)
	at PluginClassLoader for junit//hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:238)
	at Jenkins v2.479.2//hudson.FilePath$FileCallableWrapper.call(FilePath.java:3614)
	at hudson.remoting.UserRequest.perform(UserRequest.java:225)
	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
	at hudson.remoting.Request$2.run(Request.java:391)
	at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:81)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

What is your expected behavior?

JUnit reporter should be able to parse the JUnit .xml files that contain all skipped tests (no tests) without error.

How to reproduce the bug.

To reproduce the bug, run tests with mocha-opts.grep set to something that skips all tests. The resulting JUnit xml files will throw an error in Jenkin's JUnit reporter.

Relevant log output

ERROR: Step 'Publish JUnit test result report' aborted due to exception: 
java.lang.NullPointerException
	at PluginClassLoader for junit//hudson.tasks.junit.CaseResult.<init>(CaseResult.java:211)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.<init>(SuiteResult.java:487)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.parseSuite(SuiteResult.java:401)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:369)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:604)
Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to Real Device
		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1923)
		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:384)
		at hudson.remoting.Channel.call(Channel.java:1112)
		at hudson.FilePath.act(FilePath.java:1228)
		at hudson.FilePath.act(FilePath.java:1217)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitParser.parseResult(JUnitParser.java:146)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.parse(JUnitResultArchiver.java:177)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.parseAndSummarize(JUnitResultArchiver.java:282)
		at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:194)
		at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
		at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
		at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
		at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:818)
		at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:767)
		at hudson.model.Build$BuildExecution.post2(Build.java:179)
		at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:711)
		at hudson.model.Run.execute(Run.java:1854)
		at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
		at hudson.model.ResourceController.execute(ResourceController.java:101)
		at hudson.model.Executor.run(Executor.java:445)
Caused: java.io.IOException: Failed to read /home/bdermanouelian/jenkins_home/workspace/iOS UI Performance/src/ios/reports/results-undefined-undefined-0-0.xml
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:615)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parsePossiblyEmpty(TestResult.java:518)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:454)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:436)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.parse(TestResult.java:413)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.<init>(TestResult.java:259)
	at PluginClassLoader for junit//hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:238)
	at Jenkins v2.479.2//hudson.FilePath$FileCallableWrapper.call(FilePath.java:3614)
	at hudson.remoting.UserRequest.perform(UserRequest.java:225)
	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
	at hudson.remoting.Request$2.run(Request.java:391)
	at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:81)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions