- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 TestSuite 有两种配置,它们提供不同的注入(inject) bean。只要我用注释设置我的个人资料,这就有效。
@ActiveProfiles(profiles={"a"})
和 @ActiveProfiles(profiles={"b"})
但我似乎无法从属性源文件中设置它
我的注释看起来像
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AConfig.class, BConfig.class })
@PropertySource("classpath:/application.properties")
@TestPropertySource(locations = {"classpath:/application.properties"})
public abstract class AbstractTestIT {
...
}
而application.properties
的内容是
spring.profiles.active="a"
结果是不满足的依赖关系
如上所述,使用 @ActiveProfiles
进行的设置如上所述有效,并且使用了正确的设置。
这几乎就像 PropertySource 和/或 TestPropertySource 不适用于 @RunWith(SpringJUnit4ClassRunner.class)
最佳答案
This works so long as I set my profile with an annotation.
这是预期的。
ActiveProfiles
不依赖于 spring.profiles.active
属性。
ActiveProfiles is a class-level annotation that is used to declare which active bean definition profiles should be used when loading an ApplicationContext for test classes.
作为 value
属性别名的 profiles
属性需要使用配置文件进行赋值才能激活测试
The bean definition profiles to activate.
它不使用 spring.profiles.active
属性。
spring.profiles.active
属性指定哪些配置文件在应用程序的整体配置中处于 Activity 状态,而不是在单元测试上下文中。
关于java - 带有 @RunWith(SpringJUnit4ClassRunner.class) 的配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45697546/
我有一个扩展 BlockJUnit4ClassRunner 的自定义测试运行器,我想在我的自定义测试运行器中获取在 BlockJUnit4ClassRunner 中实例化的测试类的实例。 最佳答案 我
我是一名优秀的程序员,十分优秀!