java.lang.NoSuchMethodError: org.junit.vintage.engine.descriptor.RunnerTestDescriptor.getAllDescendants()Ljava/util/Set;
So, this one had me beating my head against a brick wall for a few hours; maybe I can spare somebody else
some pain by documenting what I discovered here. (Jump to the bottom for the TL;DR if you're in a hurry).
I was working on adding unit test support to my project, but when I tried to run it, I got the following
exception:
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.vintage.engine.descriptor.RunnerTestDescriptor.getAllDescendants()Ljava/util/Set;.
Well, being a professional Java programmer, I'm no stranger to incomprehensible error messages, so I did
what any of us would do — I googled the error message. My first hit was the
JUnit GIT repository. The description seemed
vaguely similar; the complainant was using IntelliJ just as I was. The suggested fix was to add an
explicit reference to junit platform launcher M3. That made perfect sense — if I was getting a
NoSuchMethodError , I must be using the wrong version of the Jar. However, when I double
checked, I was using that version of the platform launcher. Hm. Scrolling through the thread,
I couldn't find a smoking gun.
If you scroll to the very bottom of the linked thread, you'll see that when I did finally figure out what
the problem was, I did go ahead and update the thread - as you should when you solve a tricky problem!
All of the other hits I got for the same issue were similar - somebody was trying to run JUnit tests in
IntelliJ, and in every case, updating their Maven (or Gradle) dependencies resolved the issue. I started
trying different versions to see if I could hit the "magic combination", but nothing seemed to work.
Now, I've been using JUnit pretty much since it was first released. Back then, using JUnit was a simple
matter of adding a JAR file to the CLASSPATH (remembering not to deploy it at release time). Ant had some
support for this concept of test classpaths and deployment classpaths, although it was a bit
of a hassle since the test classpath "inherited" from the deployment classpath and support for that
concept was a bit clunky, but workable. Maven made this a lot more explicit by allowing you to declare
dependencies as being scoped to a particular goal. Still, adding JUnit was a matter of adding a
dependency on a particular Jar and importing the org.junit.* classes.
With JUnit 5, this has gotten a bit more complex. For one thing, although we still need a build tool
like Ant or Maven or Gradle in order to produce repeatable builds, even die-hard command line fanatics like
me have to admit that a modern IDE enhances productivity. If I'm using an IDE, of course, I expect to be
able to right-click and run my unit test and get feedback right there. Partially to support these multiple
execution modes, JUnit has split into Jupiter and Vintage. Whereas a simple dependency
declaration of:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
Allows both command-line (and therefore CI tool) execution of unit tests as well as right-click IDE usage,
the equivalent JUnit 5 declaration:
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit5-engine</artifactId>
<version>5.0.0-ALPHA</version>
<scope>test</scope>
</dependency>
Allows you to run your tests via mvn test , IntelliJ (at least build 2016.2 anyway) doesn't
recognize this as a runnable test. Instead, you add a litany of other dependencies:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0-M3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.0.0-M3</version>
<scope>test</scope>
</dependency>
This lets IntelliJ recognize this as a unit test and integrate with the IDE; the Jupiter API
exposes a lot of internals that allows the IDE to "plug in" to the unit test lifecycle. However, this
also means that all of your import statements change: rather than importing org.junit.Test
and org.junit.Assert to write your tests, you instead import
org.junit.jupiter.api.Test and org.junit.jupiter.api.Assertions . So, I'd been
working with this configuration for quite a while when all of a sudden, after adding a new unit test,
I was confronted with
java.lang.NoSuchMethodError: org.junit.vintage.engine.descriptor.RunnerTestDescriptor.getAllDescendants()Ljava/util/Set; .
Reading through the docs, I came across this,
which suggested that I may need to upgrade IntelliJ (I was, as indicated, using 2016.2.5). But still...
it does say that it should work as long as I'm willing to use this specific version, which I was,
but it still wasn't working.
After adding and removing dependencies and trying over and over again, I noticed something in my new
unit test: it wasn't importing any of the new org.junit.jupiter.api classes. If I hadn't
been poking around in vi, I might never have noticed this, because IntelliJ "helpfully" hides all of your
import statements from you — in fact, I'm almost certain that I got the classes I got because I
"alt-enter" imported my dependencies as a conscientious IDE user ought to. Instead, it was importing the
org.junit.Test dependencies. I had never removed the dependency on the old JUnit engine in
my pom (in fact, I thought - erroneously - that I still needed it for command-line support). Since the
old Jar files were still there, I accidentally imported the wrong classes. I didn't get a compile error,
and everything worked fine from the command line, but although IntelliJ did recognize the class as a unit
test, it wasn't able to actually run it.
So after all of that, the solution ended up being changing a handful of import statements. IDE's: friend
or foe?
Add a comment:Completely off-topic or spam comments will be removed at the discretion of the moderator. You may preserve formatting (e.g. a code sample) by indenting with four spaces preceding the formatted line(s) |
I'm the author of the book
"Implementing SSL/TLS Using Cryptography and PKI".
Like the title says, this is a from-the-ground-up examination
of the SSL protocol that provides security, integrity and
privacy to most application-level internet protocols, most notably HTTP.
I include the
source
code to a complete working SSL implementation,
including the most popular cryptographic algorithms
(DES, 3DES, RC4, AES, RSA, DSA, Diffie-Hellman, HMAC, MD5, SHA-1,
SHA-256, and ECC), and show how they all fit together
to provide transport-layer security.
Joshua Davies
Past Posts
- April 30, 2021: A Date Picker Control in Vanilla Javascript
- March 31, 2021: A Web Admin Console for Redis, Part Three
- January 27, 2021: A Web Admin Console for Redis, Part Two
- December 21, 2020: A Web Admin Console for Redis, Part One
- November 30, 2020: What is Procmail and why is it using up all my memory?
- September 30, 2020: Minimal Drag and Drop Support in Javascript
- August 31, 2020: Covariance and Contravariance in Generic Types
- July 31, 2020: How Spread Out Are the Floating Point Numbers?
- June 25, 2020: ERD Diagramming Tool, Part Three
- April 30, 2020: ERD Diagramming Tool, Part Two
- March 31, 2020: ERD Diagramming Tool, Part One
- February 28, 2020: MathJax and "t.setAttribute is not a function"
- December 30, 2019: Solving Systems of Equations with Python
- October 30, 2019: Linear Regression with and without numpy
- September 30, 2019: Reading a Parquet file outside of Spark
- August 30, 2019: UML Diagrams with MetaUML
- July 30, 2019: Clustering in Python
- June 25, 2019: A Walkthrough of a TLS 1.3 Handhsake
- May 31, 2019: A DataType Printer in Java
- April 30, 2019: A Simple HTTP Server in Java, Part 3 - Cookies and Keep Alives
- March 28, 2019: A Simple HTTP Server in Java, Part 2 - POST and SSL
- February 28, 2019: A Simple HTTP Server in Java
- January 29, 2019: Angular CLI Behind the Scenes, Part Two
- September 30, 2018: Angular CLI Behind the Scenes, Part One
- August 31, 2018: Into the MMIX MOR Instruction
- July 24, 2018: Undoing Percentage Changes in your Head
- June 30, 2018: Generating Langford Pairs in Scala
- May 25, 2018: Reflections on Three Years of Reading Knuth
- April 30, 2018: java.lang.NoSuchMethodError: org.junit.vintage. engine.descriptor.RunnerTestDescriptor. getAllDescendants
- March 30, 2018: An Excel Spreadsheet for the Academy Awards
- February 28, 2018: Git for Subversion Users
- January 31, 2018: The Evolution of AngularJS
- December 31, 2017: Numerical Integration in Python
- October 31, 2017: Gradle for Java Developers
- September 29, 2017: Reflections on another year of reading Knuth
- August 30, 2017: SSL OCSP Exchange
- July 27, 2017: A walk-through of an SSL certificate exchange
- June 30, 2017: A walk-through of an SSL key exchange
- May 31, 2017: A walk-through of the SSL handshake
- March 31, 2017: A walk-through of the TCP handshake
- February 28, 2017: The TLS Handshake at a High Level
- January 31, 2017: A Walk-through of a JWT Verification
- August 31, 2016: Reflections on a year of reading Knuth
- July 29, 2016: Matching a private key to a public key
- June 30, 2016: A Completely Dissected GZIP File
- May 31, 2016: Automatic Guitar Tablature Generator, Part 2
- April 28, 2016: Automatic Guitar Tablature Generator, Part 1
- March 31, 2016: Import an encrypted private key into a Java Key Store
- February 26, 2016: Import a private key into a Java Key Store
- January 31, 2016: Debian Linux on MacBook Pro
- December 29, 2015: Is Computer Science necessary or useful for programmers?
- November 30, 2015: Client certificate authentication vs. password authentication
- October 28, 2015: A Utility for Viewing Java Keystore Contents
- September 29, 2015: Debugging jQuery with Chrome's Developer Tools
- August 26, 2015: Getting Perl, MySQL and Apache to all work together on Mac OS/X
- July 30, 2015: Extract certificates from Java Key Stores for use by CURL
- June 29, 2015: Using the Chrome web developer tools, Part 9: The Console Tab
- May 28, 2015: Using the Chrome web developer tools, Part 8: The Audits Tab
- April 30, 2015: Using the Chrome web developer tools, Part 7: The Resources Tab
- March 30, 2015: Using the Chrome web developer tools, Part 6: The Memory Profiler Tab
- February 27, 2015: Using the Chrome web developer tools, Part 5: The CPU Profiler Tab
- January 31, 2015: Using the Chrome web developer tools, Part 4: The Timeline Tab
- December 31, 2014: Using the Chrome web developer tools, Part 3: The Sources Tab
- October 31, 2014: Using the Chrome web developer tools, Part 2: The Network Tab
- September 30, 2014: Using the Chrome web developer tools, Part 1: The Elements Tab
- August 11, 2014: Unable to find valid certification path to requested target
- June 30, 2014: Sort by a Hierarchy
- May 29, 2014: OpenSSL Tips and Tricks
- April 25, 2014: Heartbleed: What the Heck Happened
- February 28, 2014: Replace Microsoft Money with a Spreadsheet
- January 29, 2014: An Illustrated Guide to the BEAST Attack
- December 21, 2013: Where does GCC look to find its header files?
- October 24, 2013: Planning a Subversion import
- August 28, 2013: Compile and test an iOS app from the command line
- July 31, 2013: The Hidden Costs of Software Reuse
- June 26, 2013: Beware of mvn war:inplace
- May 29, 2013: Block Font Design Using Javascript
- April 4, 2013: Parsing a POM file using only SED
- February 22, 2013: Inside the PDF File Format
- December 31, 2012:How and why rotation matrices work
- November 27, 2012:Date Management in Java
- October 21, 2012:
Installing Debian Without a Network
- August 14, 2012:
My Review of Matt Neuburg's "Programming iOS 5"
- July 16, 2012:
An example OAuth 1.0 Handshake and mini-library
- May 23, 2012:
A Javascript one-liner to display cookie values
- April 27, 2012:
How SSL Certificates Use Digital Signatures
- March 29, 2012:
A breakdown of a GIF decoder
- February 15, 2012:
The design and implementation of LZW (the GIF compression algorithm)
- January 16, 2012:
Calculate the day of week of any date... in your head
- December 4, 2011:
Understanding CRC32
- October 29, 2011:
Efficient Huffman Decoding
- October 4, 2011:
Extract a private key from a Gnu Keyring file
- September 5, 2011:
From Make to Ant to Maven
- July 18, 2011:
A bottom-up look at the Apache configuration file
- July 6, 2011:
Fun with the HTML 5 Canvas Tag
- Jun 16, 2011:
Pain and disfiguration upon all comment spammers
- May 31, 2011:
Use of RSSI and Time-of-Flight Wireless Signal Characteristics for Location Tracking
- May 7, 2011: Implementing SSL
- Apr 24, 2011: Dissecting the GZIP format
|