I have a Spring Boot application which uses Flyway. I have created the schema and data scripts and linked them to a development profile in application-development.properties:
flyway.locations=classpath:db/migration,classpath:db/development
Everything works fine when I launch my application with this profile but there seems to be some problem when running integration tests (with mvn clean test) with it. Everytime I launch the following test, it throws exception because it is trying to migrate to version 1.1 for some reason:
org.flywaydb.core.api.FlywayException: Schema "PUBLIC" contains a failed migration to version 1.1 !
My test:
@RunWith(SpringRunner.class)
@SpringBootTest
@DirtiesContext
@ActiveProfiles("development")
public class AuditionRepositoryTest {
@Autowired
private AuditionRepository auditionRepository;
@Autowired
private EventRepository eventRepository;
@Autowired
private PersonRepository personRepository;
@Test
public void retrievesAllAuditions() {
Page<Audition> auditions = auditionRepository.findAll(new PageRequest(0, 10));
assertEquals(2, auditions.getTotalElements());
}
@Test
public void retrievesAuditionById() {
Audition result = auditionRepository.findOne(1l);
assertEquals(result.getInstrument(), Instrument.GUITAR);
assertEquals(result.getLevel(), Level.ADVANCED);
}
@Test
public void savesAuditionWithOwnerAndEventAndRetrievesItBack() {
Event event = eventRepository.findOne(1l);
Person person = personRepository.findOne(1l);
Audition audition = new Audition();
audition.setInstrument(Instrument.DRUMS);
audition.setLevel(Level.BEGINNER);
audition.setEvent(event);
audition.setOwner(person);
auditionRepository.save(audition);
Audition result = auditionRepository.findOne(3l);
assertEquals(Instrument.DRUMS, result.getInstrument());
assertEquals(Level.BEGINNER, result.getLevel());
assertEquals(person.getId(), result.getOwner().getId());
assertEquals(event.getId(), result.getEvent().getId());
}
}
Could you tell me what is going on? Is my test badly written?
EDIT: Everything works when running this test using JUnit. Just mvn test is failing.
Aucun commentaire:
Enregistrer un commentaire