You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Pr112756.aj 839B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. public aspect Pr112756 {
  2. private ThreadLocal counts = new ThreadLocal();
  3. public pointcut testMethodExecution() :
  4. execution(void Test+.test*());
  5. public pointcut assertCall() :
  6. cflow(testMethodExecution()) && call(void Assert+.assert*(..));
  7. void around() : testMethodExecution() {
  8. counts.set( new Counter());
  9. proceed();
  10. if(((Counter) counts.get()).getCount()==0) {
  11. throw new RuntimeException("No assertions had been called");
  12. }
  13. }
  14. before() : assertCall() {
  15. ((Counter) counts.get()).inc();
  16. }
  17. }
  18. class Assert {
  19. public static boolean assertEquals() { return true; }
  20. public static boolean assertSame() { return true; }
  21. }
  22. class Test {
  23. public void testFoo() {}
  24. }
  25. class Counter {
  26. int count;
  27. public void inc() { count++; }
  28. public int getCount() { return count; }
  29. }