我在IntelliJ中创建了新的Spring启动项目,我想用简单的单元测试将Spring启动上下文分开,所以我添加了maven failsafe插件。我的配置如下所示:
<!--RUNNING UNIT TESTS-->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<excludes>
<exclude>**/*IT.java</exclude>
</excludes>
</configuration>
</plugin>
<!--RUNNING INTEGRATION TESTS-->
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20</version>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我已经在intellij测试类中重命名自动生成以匹配模式和测试,如下所示:
@RunWith(SpringRunner.class)
@SpringBootTest
public class ErpegApplicationTestIT {
@Test
public void contextLoads() {
}
}
问题在于,当我在InttelliJ上运行此测试时,一切正常。但在我运行mvn verify
后,我得到了:
[ERROR] initializationError(com.tbawor.ErpegApplicationTestIT) Time elapsed: 0.005 s <<< ERROR!
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @S
pringBootTest(classes=...) with your test
类命名有问题吗?我应该采取不同的方法来分开这些测试吗?
无论如何,谢谢你的帮助。
答案 0 :(得分:1)
如果有人遇到这个问题,我找到了解决方案。您只需修改pom.xml:
Sub pastePictures()
Dim aaa As Object
Dim bbb As Range
Dim pic As String
pic = "C:\myPicture.png" ' put your picture's path here
Set aaa = Selection.InlineShapes.AddPicture( _
FileName:=pic, _
LinkToFile:=False, _
SaveWithDocument:=True)
' aaa.ScaleHeight = 10
' aaa.ScaleWidth = 10
Set bbb = aaa.Range
bbb.Select ' for debug only
bbb.Collapse wdCollapseEnd ' this collapses the range taken up by the picture to zero
bbb.Select ' for debug only
Set aaa = Selection.InlineShapes.AddPicture( _
FileName:=pic, _
LinkToFile:=False, _
SaveWithDocument:=True)
' aaa.ScaleHeight = 10
' aaa.ScaleWidth = 10
End Sub