Question: I have test:

```
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestRepositoryConfig.class})
@Transactional
public class ServiceTest {

    @Autowired
    private UserRepository userRepository;

    @Autowired
    private Service service;

static {
   initTestUser();
}

public void setUp() { 
   userRepository.seve(testUser);
}

public void test1() { ... }

public void test2() { ... }

```

I need first start method setUp, saving testUser, then start methods test1 and test2. Method setUp must performed only once! How can do it?

Answer: 
I believe the problem you are trying to solve should be done in a different way. As far as I see you want to fill your DB with some test data, and this is better to do in a global configuration for all tests.

But if you want to stick to your initial idea you can try an approach with listeners described in [this blog post](http://saltnlight5.blogspot.com/2012/09/enhancing-spring-test-framework-with.html).
Use the [@BeforeClass](http://junit.sourceforge.net/javadoc/org/junit/BeforeClass.html) annotation

```
public class MyTest {
     @BeforeClass public static void setupClass() { /* Set up stuff once */ }
     @Test public void test1() { /* ... */ }

}

```

Note however that the static method does not have access to instance members, and the things you want to set up before the tests run need to be static. It's advisable to clean up afterwards with [@AfterClass](http://junit.sourceforge.net/javadoc/org/junit/AfterClass.html)