| Mockito SBS tutorialspoint.com/mockito Environment First application Junit Integration SBS1 // Dependency in pom.xml hinzufügen <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>4.4.0</version> <scope>test</scope> </dependency> SBS2 // Create the mock object of stock service // z.B. Object from Interface StockService, welcher noch nicht implementierte Methode getPrice(googleStock) hat stockService = mock(StockService.class); SBS3 Podmena definiruetsja zaranee, eschjo do ispolzovanija when(stockService.getPrice(googleStock)).thenReturn(50.00); // Tipa when(NochNichtImplementierste, thenReturn(Eigenes Wert)); SBS4 // Vergleich value from Mock und svoego value double result = Methode, gde Mock return result == 100500.0; |