Skip to content

Reflective assertions for Class Loading #2639

Description

@ascopes

Feature summary

I would like to be able to perform assertions on classes that I load dynamically from a given classloader. This would enable me to test code that deals with custom classloaders using assertj without needing to implement my own custom boilerplate to do this.

This would have multiple cases where this could be useful, as many project such as Spring use their own special class loading strategies for certain use cases. This would also assist in testing code that is loaded using OSGi. In my specific use case it would enable testing the loading of code being passed through javac!

Example

// Given
var mySpecialClassLoader = new MySpecialClassLoader(...);

// Then
assertThat(mySpecialClassLoader)
    .hasClass("org.example.MyClass1")
    .hasResource("...")
    .class("org.example.MyClass2")
    ... // returns a ClassAssert

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions