如何在 selenium 测试 运行 JUnit4 之前真正启动 spring 启动应用程序?
How to start really spring boot application before selenium test running with JUnit4?
对于我的单元测试,我使用这些注释:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(类 = MyApplication.class)
当我尝试使用 selenium 测试 GUI 时,出现了我的问题。
在我的 gui 测试中,我调用了一些页面并验证了 html 消息的内容。
我不需要模拟,我需要在测试前启动应用程序。
什么是优雅的方式来做到这一点?
注解@SpringBootTest(类 = MyApplication.class)真正做了什么,它不启动应用程序并根据日志,它尝试启动应用程序。
您可以组合使用注释 @WebIntegrationTest
、@RunWith
和
@SpringApplicationConfiguration
。您可以找到一个工作示例 here.
对于我的单元测试,我使用这些注释:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(类 = MyApplication.class)
当我尝试使用 selenium 测试 GUI 时,出现了我的问题。 在我的 gui 测试中,我调用了一些页面并验证了 html 消息的内容。
我不需要模拟,我需要在测试前启动应用程序。 什么是优雅的方式来做到这一点?
注解@SpringBootTest(类 = MyApplication.class)真正做了什么,它不启动应用程序并根据日志,它尝试启动应用程序。
您可以组合使用注释 @WebIntegrationTest
、@RunWith
和
@SpringApplicationConfiguration
。您可以找到一个工作示例 here.