39 lines
1.0 KiB
Java
Raw Normal View History

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;
@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");
studentRepository.save(student);
}
@Test
2017-12-01 06:31:30 +01:00
public void whenInserting_andCount_thenWeDontGetZero() {
long count = studentRepository.count();
assertNotEquals(0, count);
}
@After
public void clean() {
studentRepository.deleteAll();
}
}