Community
Participate
Working Groups
The Eclipse JUnit runner won't support .aj file extensions, failing with a "Can't find type" error. I often use static inner aspects and other AspectJ-specific code in my unit tests. With the preferred support for .aj extensions, it's important to support running AspectJ unit tests.
Even worse, with Eclipse 3.1.1 and the latest AJDT dev builds, if I make a unit test with a static inner aspect have a .java extension, the JUnit test runner just hangs. It eventually fails like this: Could not connect to: : 4837 java.net.ConnectException: Connection refused at jrockit.net.SocketNativeIO.connect (Ljava.io.FileDescriptor;Ljava.net.InetAddress;III)I(Unknown Source) at java.net.AbstractSocketImpl.doConnect(Ljava.net.InetAddress;II)V (Unknown Source) at java.net.PlainSocketImpl.doConnect(Ljava.net.InetAddress;II)V (Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Ljava.net.InetAddress;II)V (Unknown Source) at java.net.PlainSocketImpl.connect(Ljava.net.SocketAddress;I)V(Unknown Source) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364) at java.net.Socket.connect(Socket.java:507) at java.net.Socket.connect(Socket.java:457) at java.net.Socket.<init>(Socket.java:365) at java.net.Socket.<init>(Socket.java:178) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.connect (RemoteTestRunner.java:754) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java:336) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java:196)
I agree this is pretty bad, but we're not going to be able to address it in this release. The JUnit support is parsing the source code to locate the tests, so it's thrown by the .aj extension or the inner aspect. We're either going to have to propose that JUnit is made tolerant of this, or provide our own "JUnit with AspectJ support" launch config. Note that this doesn't stop you using AspectJ in unit tests (we do plenty of this ourselves), you just need to use a TestSuite class in which you add all of your unit tests.
Fixed in 1.4.0.20060219125111 for Eclipse 3.2M5. You can now do Run As > JUnit test on .aj files.