almondtools / testrecorder

Create Test Fixtures from Runnable Java Code
http://testrecorder.amygdalum.net/
GNU Lesser General Public License v3.0
51 stars 5 forks source link

Type error with nested enums #17

Closed maxbechtold closed 7 years ago

maxbechtold commented 7 years ago

The following reveals a problem with a nested enum (static), leading to a compile error in the generated test. The error is that value() returns Object, and the compiler 'cannot convert from Object to Wrapped'.

 File file2 = new GenericObject() {
    Path filePath = null;
    String path = "test.out";
    int prefixLength = 0;
    Wrapped status = Wrapped.enumType("java.io.File$PathStatus", "CHECKED").value();
    }.as(File.class);

It is, however, the only error in 3000+ lines of generated code, so hats off!

almondtools commented 7 years ago

Thanks for reporting, I created a unit test to reproduce the behaviour.

Apart from the bug - File is also a good candidate that should be handled by a custom serializer/deserializer. Yet documentation on the subject custom serializer/deserializer is short.

almondtools commented 7 years ago

The enum problem (along with some other problems) should work now. Can you verify? Do you need a snapshot in the public maven repository?

maxbechtold commented 7 years ago

Currently, no, the test that triggers the snapshot runs into another error, independent of this fix. I hope I can try it soon. I'm sorry, but I also spammed this thread with a mistaking pull and push on my fork - probably due to line endings differing (CR/CRLF)...

almondtools commented 7 years ago

It seems that two scenarios cause errors with enums:

I will come with some test cases and a solution soon.

almondtools commented 7 years ago

There were no new problems with enums so I close this issue.

maxbechtold commented 7 years ago

I can confirm it works with testrecorder 0.2.11