Prev Next

DevOps / Maven Surefire Plugin Interview Questions

Why might a ClassNotFoundException appear only when tests run via Surefire, not in the IDE?

This usually points to a classpath mismatch between the forked test JVM and your IDE's own runtime — often caused by a dependency scoped as provided that tests actually need at runtime, shaded/relocated dependencies, or useSystemClassLoader settings that change how the classpath is assembled for the fork.

Which dependency scope commonly causes this kind of mismatch?

More Related questions...

What is the Maven Surefire Plugin? What is the difference between the Surefire and Failsafe plugins? Which lifecycle phase does Surefire bind to by default? How do you skip tests entirely when running a Maven build? What's the difference between skipTests and maven.test.skip? What does the testFailureIgnore configuration do? How do you include or exclude specific test classes in Surefire? What naming convention does Surefire use to auto-detect test classes? How do you run a single test class from the command line? Can wildcards be used with the -Dtest property? How do you configure parallel test execution in Surefire? What is forkCount and how does it differ from reuseForks? What is the purpose of the argLine parameter? Where does Surefire store its test result reports? How do you generate an HTML report from Surefire's results? Does the Surefire Plugin support TestNG out of the box? How do you run JUnit 5 tests using Surefire? How do you run only tests with a specific JUnit 5 tag or TestNG group? How can you make Surefire automatically retry a failing test? How do you set a timeout so a hung test doesn't block the build forever? How does Surefire integrate with JaCoCo for code coverage? How do you pass system properties into your tests through Surefire? How do you set environment variables for the test JVM in Surefire? How do you exclude tests by category or tag, not file name? What happens if Surefire can't find any tests to run? What does the useSystemClassLoader option control? How do you control the order tests run in? What does redirectTestOutputToFile do? How do you keep integration tests separate from unit tests in a Surefire/Failsafe setup? What is the testSourceDirectory element used for? How do you debug tests that run through Surefire? What does the printSummary configuration control? What are the valid values for the reportFormat option? How can you stop a multi-module build as soon as one module's tests fail? How is Surefire typically configured across a multi-module Maven project? What does the provider configuration control in Surefire? Why might a ClassNotFoundException appear only when tests run via Surefire, not in the IDE? What does a "Fork failed" or "Error occurred in starting fork" message usually mean? How can you skip tests only within a specific Maven profile? What's the difference between excludes and excludedGroups? Can Surefire output test results directly as JSON for a custom dashboard? Can Surefire run tests written in Kotlin or Groovy? How does testFailureIgnore differ from wrapping test code in a try/catch? How do you exclude certain tests only on a specific operating system? How do you increase heap size for tests without touching the main build JVM? How does Surefire distinguish a test failure from a test error? Why might tests pass locally but fail in CI when using Surefire? How should Surefire be integrated into a CI/CD pipeline effectively? What notable improvements have appeared in recent Surefire Plugin versions?
Show more question and Answers...


Comments & Discussions