我安装了Sprint Tool Suite 3.3和最新版本的Infinitest。根据Infinitest的说法,我的很多课程都有错误,但Maven构建得很好。以下是STS中“问题”选项卡显示的一些错误示例:
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
显示错误的所有测试都是使用Java Config for EmbeddedDatabase的集成:
public class TestMenuBuilderIT extends BaseItegration {
@Autowired
private MenuRepository menuRepository;
@Test
public void sortByTopMenu() {
List<Menu> testMenu = menuRepository.findAll(); <== offending line
...
}
配置类:
@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();
}
我不明白为什么这在Maven中可行,但Infinitest有这些与DB相关的错误。我找不到任何文档说JavaConfig不适用于Infinitest。我可以右键单击并成功运行每个测试“作为单元测试”。
有谁知道可能导致这种情况的原因?