Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why do I get an error (ClassCastException or LinkageError) using the GUI TestRunners?

0
Posted

Why do I get an error (ClassCastException or LinkageError) using the GUI TestRunners?

0

(Submitted by: Scott Stirling) JUnits GUI TestRunners use a custom class loader (junit.runner.TestCaseClassLoader) to dynamically reload your code every time you press the “Run” button so you don’t have to restart the GUI to reload your classes if you recompile them. The default classloaders of the Java Virtual Machine do not dynamically reload changed classes. But JUnits custom class loader finds and loads classes from the same CLASSPATH used by the JVMs system classloader. So, by design, it “sits in front of” the system loader and applies a filter to determine whether it should load a given class or delegate the loading of a class to the system classloader. This filter is configured with a list of String patterns in a properties file called excluded.properties. The excluded.properties file contains a numbered list (excluded.0, excluded.1, excluded.2, etc.) of properties whose values are patterns for packages. This file is packaged in junit.jar as junit/runner/excluded.properties.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.