blob: f1ce5c7aea88adaa58b6e55df680295a4f15b613 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
public aspect Pr112756 {
private ThreadLocal counts = new ThreadLocal();
public pointcut testMethodExecution() :
execution(void Test+.test*());
public pointcut assertCall() :
cflow(testMethodExecution()) && call(void Assert+.assert*(..));
void around() : testMethodExecution() {
counts.set( new Counter());
proceed();
if(((Counter) counts.get()).getCount()==0) {
throw new RuntimeException("No assertions had been called");
}
}
before() : assertCall() {
((Counter) counts.get()).inc();
}
}
class Assert {
public static boolean assertEquals() { return true; }
public static boolean assertSame() { return true; }
}
class Test {
public void testFoo() {}
}
class Counter {
int count;
public void inc() { count++; }
public int getCount() { return count; }
}
|