GithubHelp home page GithubHelp logo

Comments (4)

Mixermachine avatar Mixermachine commented on August 30, 2024 1

Hy @Santobert,

yes this seems like a blind spot.
The fix might take some time as I'm currently loaded with my thesis.

Thanks for bringing it up :)

from base-test.

Mixermachine avatar Mixermachine commented on August 30, 2024

Hy @Santobert

I have worked on this issue for some time now.
The line

if (getClass() != obj.getClass())
			return false;

is not the problem.

The problem is generating a class that
fullfills the combination of

if (!super.equals(obj))
			return false;
if (getClass() != obj.getClass())
			return false;

A class which has the same super class, but not the Child class itself.
So for example:
Parent class: Mammal
Child class: Human

I would need to create an extending class (an Elephant class for example) on the fly.
It would be possible to search for other classes with the same super class, but this will fail if there is no other class that extends the super class (Mammal). -> Flaky tests

Java Reflections can not define classes on the fly (at least not to my knowledge).
Thats where custom classloader and byte code manipulation come into play.
Something like https://stackoverflow.com/a/2320465 (requires sun dependencies, which are not included in the OpenJDK) or the PowerMock lib (https://github.com/powermock/powermock) can help there.
The jOOR lib (https://github.com/jOOQ/jOOR) seems to work well, although there will be problems with classloader.

I guess I can get it to work, but this will definitely add a lot of execution time to the tests and I doubt that I can get it to work over all suported Java version (8 - 13) seamlessly.

Maybe I don't see the easy solution.
What are your thoughts @Santobert ?

from base-test.

Santobert avatar Santobert commented on August 30, 2024

What do you think about giving the user the option to create this class. That works great for test data providers. Why not for this case as well?

from base-test.

Mixermachine avatar Mixermachine commented on August 30, 2024

Yes that is definitely an option.
Something like addSibling(Class<?> siblingClass)

I will look into it.

from base-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.