Hello.
My name is Evgeny Frolikov, I'm a developer at AlfaStrakhovanie
In the course of work on a project at AlfaStrakhovanie, we are writing a project on micro services and it turned out that one of the "micro services" has grown greatly (but it is still far from the monolith :)). We lived so happily ever after, until we began to "move" to the cloud, and then the adventure began.
The move was not particularly memorable for the development team, only with questions from DevOps about ports, etc. Note that we cut out all the integration tests in order to get rid of dependence on other teams when something falls on their test benches. But "magic" began to happen in JUnit tests, namely tests began to fail. They fell phantom and unpredictably, for the time being it was treated with a retraem pipeline, until this problem became a blocker for calculating changes.
retraem
" " .
( ) . ( , c Sonar).
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class ContractStatusServiceTest {
@Autowired
private ContractStatusService contractStatusService;
@MockBean
private RsaInfoComponent rsaInfoComponent;
@MockBean
private ContractRepository contractRepository;
""
@RunWith(SpringJUnit4ClassRunner.class) - Spring
@SpringBootTest - Spring Boot (, @SpringBootApplication) Spring. SpringBootTest
@Autowired - Bean;
@Autowired , .
.
@RunWith(SpringRunner.class)
@SpringBootTest
@RequiredArgsConstructor
public class ComponentTestTest {
// @Autowired
private final ComponentTest componentTest;
,
1)@RequiredArgsConstructor - Lombok final.
.....
java.lang.Exception: Test class should have exactly one public zero-argument constructor
at org.junit.runners.BlockJUnit4ClassRunner.validateZeroArgConstructor(BlockJUnit4ClassRunner.java:171)
at org.junit.runners.BlockJUnit4ClassRunner.validateConstructor(BlockJUnit4ClassRunner.java:148)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:127)
...
.
, Mock
@RunWith(MockitoJUnitRunner.class)
public class CrossProductServiceTest {
@InjectMocks
private CrossProductService crossProductService;
@Mock
private KaskoService kaskoService;
@Mock
private CrownVirusOfferService crownVirusOfferService;
"".
:
( )
: