クラスの (ユニット) テストをどの程度深く行うべきか自問自答しています。例として、次の単純なクラスがあります。
import javax.annotation.security.PermitAll;
import javax.ejb.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path(value = "ping")
@Singleton
@PermitAll
public class PingRestService {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String pingMethod(){
        return "pong";
    }
}
次の単体テストを作成しました。
import static org.junit.Assert.*;
import java.lang.reflect.Method;
import javax.annotation.security.PermitAll;
import javax.ejb.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.junit.Test;
public class PingRestServiceTest {
    PingRestService prs = new PingRestService();
    @Test
    public void testClassAnnotations(){
        assertEquals(3, prs.getClass().getAnnotations().length);
        assertTrue(prs.getClass().isAnnotationPresent(PermitAll.class));
        assertTrue(prs.getClass().isAnnotationPresent(Singleton.class));
        assertTrue(prs.getClass().isAnnotationPresent(Path.class));
        assertEquals("ping", prs.getClass().getAnnotation(Path.class).value());
    }
    @Test
    public void testPingMethodAnnotations() throws SecurityException, NoSuchMethodException{
        Method method = prs.getClass().getDeclaredMethod("pingMethod");
        assertEquals(2, method.getAnnotations().length);
        assertTrue(method.isAnnotationPresent(GET.class));
        assertTrue(method.isAnnotationPresent(Produces.class));
        assertEquals(1, method.getAnnotation(Produces.class).value().length);
        assertEquals(MediaType.TEXT_PLAIN, method.getAnnotation(Produces.class).value()[0]);
    }
    @Test
    public void testPingMethod() {
        assertEquals("pong", prs.pingMethod());
    }
}
それは理にかなっていますか?または、すべての注釈テスト (testClassAnnotations、testPingMethodAnnotations) をスキップして、返される文字列 ("pong"、testPingMethod) のみをテストする必要がありますか?
一部の注釈はビジネス ロジック (PermitAll など) の一部であるため、テストする必要があると思います。