Results 1 to 2 of 2

Thread: Can you apply aspects to a spring test?

  1. #1

    Question 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.
    javapda on forum

  2. #2
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    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).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •