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.

Tests requiring AssertJ Swing as a Maven dependency encounter a NoClassDefFoundError under Pit

See original GitHub issue

I have some JUnit tests for my Swing GUI using AssertJ-Swing, which work fine under other Maven test goals, but they crash out when running Pit. In addition, my other (non-AssertJ) tests work fine with Pit. This issue occurs for both OpenJDK 11 and OpenJDK 8.

The exact issue I am facing is that a java.lang.NoClassDefFoundError is thrown when running any AssertJSwingJUnitTestCase, when it tries to access org.assertj.swing.core.BasicRobot.

I have all of my testing dependencies included in my pom.xml, under the test scope. I have also tried explicitly including AssertJ JAR as additional classpath elements. I’ve uploaded a gist of my pom.xml here: https://gist.github.com/ben-clegg/c73660b2cdbc82d01dbdcd038fd23adb

Since this works fine with other Maven goals, I believe this is an issue with Pit. Does Pit have similar issues with other Maven dependencies, or is this unique to AssertJ? Can you suggest any workarounds?

Thanks

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
StefanPenndorfcommented, May 11, 2021

As your stacktraces tell HeadlessGraphicsEnvironment will be used which fails with HeadlessException in either gist. You cannot disable headless for test minions due to #581 .

The change merged in #601 adds -Djava.awt.headless=true to every mutation minion created. There is only the option to add further settings but not to remove the default.

So far so good. The problems seems the new default introduced in #601 .

@hcoles What do you think would be the best solution: Remove the default and warn Mac users that they should add -Djava.awt.headless=true themselves or should one introduce another configuration option that lets one turn headless on/off ?

0reactions
hcolescommented, Jul 14, 2022

This will work differently in pitest 1.9.3. once #1054 is merged.

Auto adding of the jvm arg can be disabled with -Dfeatures=“-macos_focus”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tests requiring AssertJ Swing as a Maven dependency encounter a ...
I have some JUnit tests for my Swing GUI using AssertJ-Swing, which work fine under other Maven test goals, but they crash out...
Read more >
NoClassDefFoundError on Maven dependency - Stack Overflow
A better solution is to "shade" the library code into your output JAR file. There is a Maven plugin called the maven-shade-plugin to...
Read more >
AssertJ / Fluent assertions for java - GitHub Pages
AssertJ Swing artifacts are in Maven central repository. There are two main artifacts: assertj-swing-testng and assertj-swing-junit . It should be obvious that ...
Read more >
Release Notes - Java Bug System - OpenJDK
toURL in com/sun/java/swing/plaf/gtk/Metacity.java - toURL known to return invalid URLs ... and hexBinary: 75 tests fail with ClassNotFoundException ...
Read more >
Better looking HTML test reports for TestNG with ReportNG
One more thing. Unfortunately ReportNG jar isn't available in Maven Central Repository, so it could be required to add java.net repository in ......
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