-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Records cannot be customised #87
Comments
In order for this to work, we would need access to the "id":"hello"-mapping when we use a constructor for an object. |
While trying to test this I found that we can do this for records, but not for "normal" classes. public record MyRecord(String id) {} but not with public class MyRecord {
String id;
public MyRecord(String id) {
this.id = id;
}
} The constructor parameter will show up as I propose the following behaviour:
|
It's a bummer that "normal" classes use generic constructor-parameter names. On the other hand, I'm also a little bit glad about this, because otherwise it would seem very very magical, at least as long those parameter-names can even change depending on how you compile your code (as you explained to me the other day).
I think this is the best way to go for now.
Pragmatism is always a good way to go. In case we run into trouble, I can see another possible option to overcome this, albeit a potentially invasive one. So let's see if we really need it.
I agree. I think we're in sync. Good work! |
Fixed in version 2.9.6. |
I remember that despite Fixture being compiled in Java 11, we (or rather one of my amazing co-authors) once enabled it to successfully create records when used in a Java 17 application.
Now, in Java 17, I find myself unable to customise the behaviour:
This test is red, as
id
will still contain a random string value.Now, the bonus challenge is: How do we test records in an environment (Java 11) that doesn't provide records?
The text was updated successfully, but these errors were encountered: