How can I ignore spring @Transactional annotation for a specific method when @ActiveProfiles("test")

Viewed 2687

I need to ignore the following @Transactional annotation during my integration tests.

@Service
public class MyClass {

    @Transactional(propagation = Propagation.NEVER)
    public void doSomething() {
        // do something that once in production can not be inside a transaction (reasons are omitted)
    }

}

The problem is that all my tests are executed inside a transaction that is rolled back by default. How could I ignore the @Transactional(propagation = Propagation.NEVER) annotation for this method when it is running in the scope of a test (@ActiveProfiles("test")) allowing it to be executed inside a transaction?

1 Answers
Related