Skip to content
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

Remove not needed casts in generated tests to have more readable tests #688

Closed
vmassol opened this issue Feb 4, 2019 · 3 comments
Closed
Labels
prettifier This issue is related to the module DSpot - Prettifier task available

Comments

@vmassol
Copy link
Contributor

vmassol commented Feb 4, 2019

Example of generated test (showing a screenshot that shows in light grey what can be removed)

screenshot 2019-02-04 at 09 33 59

@vmassol
Copy link
Contributor Author

vmassol commented Feb 4, 2019

BTW a very simple thing to do is to do a static import for import static org.junit.jupiter.api.Assertions.*;. This removes all the Assert. prefixes and make the code more readable too. :)

@vmassol
Copy link
Contributor Author

vmassol commented Feb 4, 2019

Side question: I see this tests calls:

        type.getType().getId();
        type.getDataFormat();
        type.getVersion();

And then does the same assert again. Couldn't dspot decide to not add the second part since calling the getters has no side effects?

@danglotb danglotb added task available prettifier This issue is related to the module DSpot - Prettifier labels Feb 4, 2019
@danglotb
Copy link
Member

danglotb commented Feb 4, 2019

Hi @vmassol

I'll look at the redundant cast.

BTW a very simple thing to do is to do a static import for import static org.junit.jupiter.api.Assertions.*;. This removes all the Assert. prefixes and make the code more readable too. :)

This issue comes from Spoon if I remember. A release is announced on the 11th, February. I'm gonna bump the version used by DSpot.

Couldn't dspot decide to not add the second part since calling the getters has no side effects?

It could. For now, DSpot does not distinguish the "type" of statement between the sequences of assertions. If there is something, (invocation, local variables, etc...) It should generate the second sequence.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prettifier This issue is related to the module DSpot - Prettifier task available
Projects
None yet
Development

No branches or pull requests

2 participants