I wanted to check the class specification so that when annotating the getter method, the tests would not run and warn that the class specification had changed.
class SomeBean{ @XMLElement(name = "name") public String getName(){ return name; } } class SomeBeanUnitTest{ @Test public void test_getNameMustHaveAnnotation(){ Method getNameMethod = SomeBean.class.getDeclaredMethod("getName", new Class<?>[]{}); assertNotNull(getNameMethod.getAnnotation(XmlElement.class)); } }
Ways to check declared annotations - is this the right way to check class specification? Since this will make the tests more fragile, but it will provide the correct feedback that the annotation has been removed from the getter method. Is it advisable to write such tests?
This condition is even considered in the integration test, but the feedback provided by the integration will not indicate a problem.
It depends.
, / . , , , , .
- , , , , [Transaction]. ? :
[Transaction]
, [Transaction], . . , , , , , , . / .
, @XMLElement , , , . , . , , / ( ), .
@XMLElement