angular
무료Conventions for Angular applications
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Conventions for dependency injection and mocking in Spring Boot integration tests in this project. Use this whenever writing, reviewing, or refactoring integration test classes (anything annotated @SpringBootTest, or under src/test that talks to a real Spring context), especially when deciding how to wire dependencies or mock collaborators. Also consult this before adding @Autowired, @MockBean, @MockitoBean, or field injection in any test class.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
설치 방법 보기설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.
Rules for how dependencies get injected and mocked in this project's integration tests. Apply these whenever creating a new integration test class or reviewing/editing an existing one.
Integration test classes must wire their dependencies through the constructor, never through @Autowired fields.
This skill applies to all modules and submodules of the whole project. This means that all tests made in Kotlin are a
subject of this skill. Only Kotlin files, the ones with the .kt extension should be subject to this change. No other
files should be affected.
Do:
@SpringBootTest
class JeorgActionAOPLauncherExtAOPTest @Autowired constructor(
private val bonitoCatcher: BonitoCatcher,
private val codCatcher: CodCatcher
) {
}
Don't:
@SpringBootTest
class JeorgActionAOPLauncherExtAOPTest() {
@Autowired
lateinit var bonitoCatcher: BonitoCatcher
@Autowired
lateinit var codCatcher: CodCatcher;
}
Notes:
@Autowire annotated fields or
params, that they
get injected via the mentioned above @Autowired constructor pattern.TestConstructor support allows constructor injection in test classes the same way it works in
production beans. If the project hasn't set spring.test.constructor.autowire.mode=all in
application-test.properties (or via @TestConstructor(autowireMode = ALL)), the constructor still needs an explicit
@Autowired annotation as shown above — include it only in the constructor and remove it from the fields, or the
injected params.private val.@Autowired constructor pattern is already in use, make sure that all injected params are private val, but
also remove @Autowire if they have it.@MockitoBean, @MockBean, @SpyBean, @MockkBean, @MockkSpyBean, or
others, and injected with lateinit, please put them with the correct annotation in the constructor as wellWhen finding this:
initMocks(testRestTemplate)
Replace with:
openMocks(testRestTemplate)
Also replace imports from import org.mockito.MockitoAnnotations.initMocks to import org.mockito.MockitoAnnotations.openMocks
@MockBean annotationsThe annotation @MockBean is deprecated and its usage needs to be replaced by @MockitoBean
The annotation @SpyBean is deprecated and its usage needs to be replaced by @MockitoSpyBean
The above annotations should be updated in the same way following the examples bellow.
On a class level, replace this:
@MockBean(Planet.class)
private MyService myService;
with this:
@MockitoBean(types = Planet.class)
private MyService myService;
Replace also the usages of import org.springframework.boot.test.mock.mockito.MockBean; with import org.springframework.test.context.bean.override.mockito.MockitoBean;
The beans that are declared are like this:
@MockBean
private BankCompanyBankRepository bankCompanyBankRepository;
should be replaced to something like:
@MockitoBean
private BankCompanyBankRepository bankCompanyBankRepository;
Please add:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
as a dependency for projects that use WebMvcTest
Replace the import: import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest to org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest
The syntax is slightly changed in the latest Spring MocK versions.
Changes in MockKBean
Replace @MockkBean(classes = [DataSource::class]) with @MockkBean(types = [DataSource::class])
Creating entities via JPA should assume the usage of an ID autogeneration engine. It could be a sequence, or something else, like a counter, entity, or any other strategy If creating an entity like this, somehow works and is used in the test, the test should be updated so that it does not use a fixed ID on the entity creation and persistence to the database.
Updates and other CRUD methods should be left as is. Only on creation should the above be considered.
Before submitting/reviewing an integration test class, confirm:
@Autowired (unless project-wide TestConstructor autowire mode is configured)@Autowired on fieldsAntPathRequestMatcher anymore. Make sure none is used@MockBean or @SpyBean annotations are used. Use @MockitoBean or @MockitoSpyBean instead.@MockkBean(classes = type of declarations leftimport org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.
로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.
아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.
Conventions for Angular applications
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Conventions for using annotations in all tests using Jupiter
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Conventions for docker
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Conventions for using in all JEE frameworks. These are common standards for CDI
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Conventions for using in all JVM languages
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Conventions for using Java
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.