2017-11-29 04:30:45 +01:00
|
|
|
package com.baeldung;
|
|
|
|
|
|
|
|
import com.baeldung.domain.Student;
|
|
|
|
import com.baeldung.repository.StudentRepository;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
2017-12-01 06:31:30 +01:00
|
|
|
|
|
|
|
import static org.junit.Assert.assertNotEquals;
|
2017-11-29 04:30:45 +01:00
|
|
|
|
|
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
|
@SpringBootTest
|
|
|
|
public class SomeIntegrationTest {
|
|
|
|
@Autowired
|
|
|
|
private StudentRepository studentRepository;
|
|
|
|
|
|
|
|
@Before
|
|
|
|
public void setup() {
|
2017-12-01 06:31:30 +01:00
|
|
|
Student student = new Student("Paul", "Smith", "64377473774", "me@mailprovider.com");
|
2017-11-29 04:30:45 +01:00
|
|
|
studentRepository.save(student);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2017-12-01 06:31:30 +01:00
|
|
|
public void whenInserting_andCount_thenWeDontGetZero() {
|
2017-11-29 04:30:45 +01:00
|
|
|
long count = studentRepository.count();
|
|
|
|
|
|
|
|
assertNotEquals(0, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
@After
|
|
|
|
public void clean() {
|
|
|
|
studentRepository.deleteAll();
|
|
|
|
}
|
|
|
|
}
|