Comments (4)
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.
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.
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.
Yes that is definitely an option.
Something like addSibling(Class<?> siblingClass)
I will look into it.
from base-test.
Related Issues (20)
- PublicVariableCheck should ignore public static final values
- Improve logging of where checks failed HOT 1
- HashCodeEqualsCheck should set boolean values always to true HOT 1
- HashcodeAndEqualsCheck shoud check with additional objects HOT 1
- Checker should catch all known exceptions
- Complete wiki page about TestDataProvider HOT 1
- Rework TestDataProvider
- Implement a ToString checker
- Reorder folder structure HOT 1
- Add separate getter and setter checks
- Collect logs of test executions for better visibility of errors
- Lombok EqualsAndHashcode is not fully tested
- Introduce strict mode
- Introduce builder instead of complex check constructors HOT 1
- Regex in GetterIsSetterCheck HOT 2
- Flaky tests with HashcodeAndEqualsCheck and java.util.Date HOT 3
- Wrapped primitives do not use origin primitive
- EmptyCollectionCheck should not use class.newInstance()
- HashcodeAndEqualsCheck should not use class.newInstace()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from base-test.