Infinitest fails but Maven works

312 Views Asked by At

I have Sprint Tool Suite 3.3 and the latest version of Infinitest installed. According to Infinitest, many of my classes have errors, but yet Maven builds just fine. Here is an example of some errors that the Problems tab in STS show:

  • InvalidDataAccessResourceUsageException (Table "ADDRESSTYPEREF" not found; SQL statement:...SeedAddressTypes.java /... line 34 Infinitest Test Failure
  • AssertionFailure (null id in com..model.base.Menu entry (don't flush the Session after an exception occurs)) in TestMenuBuilderIT.sortByTopMenu TestMenuBuilderIT.java

All the tests that show an error are integration that use Java Config for the EmbeddedDatabase:

public class TestMenuBuilderIT extends BaseItegration {
@Autowired
private MenuRepository menuRepository;
     @Test 
     public void sortByTopMenu() {
          List<Menu> testMenu = menuRepository.findAll();  <== offending line
...
}

And the configuration class:

@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = { JpaConfig.class } )
public abstract class BaseItegration {
..
}

@Configuration
@EnableTransactionManagement
@ComponentScan( basePackages = { ...} )
@ImportResource( { "classpath:applicationContext.xml"} )
public class JpaConfig {

@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder().setType( EmbeddedDatabaseType.H2 ).setName( "testdb" )
.addScript( "classpath:embeddedDatabase.sql" ).build();
}

I don't see why this would work fine in Maven, but Infinitest has these DB related errors. I could not find any documentation saying that JavaConfig wouldn't work with Infinitest. I am able to right click and run each test "As A Unit Test" successfully.

Does anyone know what might cause this?

0

There are 0 best solutions below