Skip to content

Complain when @Test is applied to an inappropriate method #1074

@islandsvinur

Description

@islandsvinur

Overview

When writing tests in Groovy, it's tempting to use def for the test methods, since that is typically the way to go in Groovy. However, for def the compiler produces a method that returns Object.

If this was a method annotated with @Test, it would be silently ignored by JUnit, as it should be a void method. This leads to lots of pulled hairs and other frustrations.

Test run finished after 13 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         0 tests found           ]
[         0 tests skipped         ]
[         0 tests started         ]
[         0 tests aborted         ]
[         0 tests successful      ]
[         0 tests failed          ]

I would like JUnit to shout in my face that I'm using it wrong.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions