Announcement Announcement Module
Collapse
No announcement yet.
Can you apply aspects to a spring test? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can you apply aspects to a spring test?

    If you have a spring test
    Code:
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations={"classpath:spring-test-config.xml"})
    public class MyTransactionSpringTest {
    
       @Test
       public void testSomething() {
       }
    }
    Can you apply aspects to it? For example, if you did not want to apply the @Transactional annotation on the test method (or class) but instead wanted to apply them in an aspect.

    Thanks in advance.

  • #2
    Your question is a bit confusing, I don't understand what you're really trying to do. Anyway, you can't apply aspects on a JUnit test class, but the aspects you defined in your test application context DO get applied to your Spring beans, even when running JUnit tests (we are talking about Spring AOP here, AspectJ needs some configuration to be set up to run with JUnit).

    Comment

    Working...
    X