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.

PowerMock/Mockito Tests are failing after Sorting pom.xml

See original GitHub issue

Hello, After sorting my pom.xml suddenly the tests are not running anymore. after reverting the pom.xml, it works again.

<plugin>
                    <groupId>com.github.ekryd.sortpom</groupId>
                    <artifactId>sortpom-maven-plugin</artifactId>
                    <version>${version.sortpom-maven-plugin}</version>
                    <configuration>
                        <predefinedSortOrder>recommended_2008_06</predefinedSortOrder>
                        <keepBlankLines>true</keepBlankLines>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <sortDependencies>scope,artifactId</sortDependencies>
                        <sortPlugins>groupId,artifactId</sortPlugins>
                        <sortProperties>false</sortProperties>
                        <sortModules>true</sortModules>
                        <createBackupFile>false</createBackupFile>
                        <ignoreLineSeparators>false</ignoreLineSeparators>
                        <nrOfIndentSpace>4</nrOfIndentSpace>
                        <indentBlankLines>false</indentBlankLines>
                    </configuration>
                </plugin>
java.lang.ExceptionInInitializerError
        at my.project.pkg.esb.dispatch.MessageDispatcherTest.setUp(MessageDispatcherTest.java:102)
Caused by: java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.StackTraceCleanerProvider (alternate: null)
        at my.project.pkg.esb.dispatch.MessageDispatcherTest.setUp(MessageDispatcherTest.java:102)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.StackTraceCleanerProvider implementation declared in java.lang.CompoundEnumeration@47cb2624
        at my.project.pkg.esb.dispatch.MessageDispatcherTest.setUp(MessageDispatcherTest.java:102)
Caused by: java.lang.ClassCastException: **Cannot cast org.powermock.api.mockito.internal.exceptions.StackTraceCleanerProvider to org.mockito.plugins.StackTraceCleanerProvider**
        at my.project.pkg.esb.dispatch.MessageDispatcherTest.setUp(MessageDispatcherTest.java:102)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Ekrydcommented, Jan 14, 2020

I have been using SortPom together with Jenkins, but then I use the verify goal instead. Each developer must sort the pom (often just by building the project) before they make a checkin.

The verify goal will fail the build if the pom is not sorted, same as it fails the build if tests are not successful.

So the Jenkins server will never sort the pom

1reaction
razisamcommented, Jan 14, 2020

thanks for the advices and hints. i’m getting rid of easymock. that is the best way. ticket can be closed.

other Question: what is your experience with sortpom-plugin plus Jenkins CI. Currently i have to tell my Jenkins-Job to clean checkout from SVN, otherwise there will be always an merge conflict in pom.xml when run the job the second time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dropwizard + Powermock + Mockito + Maven build error with ...
1 Answer 1 ... when you are defining the power mock jars in pom.xml, you don't need to explicitly define dependent jars as...
Read more >
Java 11 compatibility with inline mocks · Issue #1483 - GitHub
Using the latest version of Mockito (2.22.0), simply adding the following as a test dependency to my pom.xml allowed the tests to run ......
Read more >
PowerMock tests work fine in Eclipse, but don't execute in ...
I'm trying to write some tests using PowerMock. I got the PowerMock test working fine in Eclipse, but now I'm noticing that the...
Read more >
How to Fix A "Mockito cannot mock this class" Exception in A ...
IllegalStateException: Failed to load ApplicationContext Caused by: org.mockito.exceptions.base.MockitoException: Mockito cannot mock this ...
Read more >
Maven Surefire Plugin – Using JUnit
Use mvn dependency:tree , POM dependency ordering and/or ... Failing to add the proper test-frameworks will result in a build failure.
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