38 lines
987 B
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;
import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class SomeIntegrationTest {
@Autowired
private StudentRepository studentRepository;
@Before
public void setup() {
Student student = new Student("Paul", "Smith", "64377473774", "me@mymail.com");
studentRepository.save(student);
}
@Test
public void testDB() {
long count = studentRepository.count();
assertNotEquals(0, count);
}
@After
public void clean() {
studentRepository.deleteAll();
}
}