mardi 2 juin 2015

How can performed method setUp only once in tests

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?

Aucun commentaire:

Enregistrer un commentaire