Java – automatically create unit tests (semi)?

Is there a framework that supports generating some standard unit tests from annotations? An example I think of is:

@HasPublicDefaultConstructor
public class Foo {

}

This will obviously be used to automatically generate a unit test to check whether foo has a default constructor Am I the only one who thought of such a person? Although I am most interested in Java, solutions in other languages must be interesting

Editor: in response to S. Lott's answer, let me clarify:

I'm trying to test whether the class has a default constructor (of course, this is just an example.) I can do this by writing tests, but I find it boring So I'm looking for a tool that can process comments at compile time (through APT) and generate tests for me Does such a thing exist? If not, do you think it's a good idea?

Solution

The question is, is it really a good idea to "pollute" production code with unit test information in the form of annotations I personally voted against it

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>