Created
March 14, 2024 14:52
-
-
Save FranckSilvestre/3396da73fa72c2289316a4faab389ce6 to your computer and use it in GitHub Desktop.
v1 on OurBusinessProject 2023-2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ourbusinessproject; | |
import org.junit.jupiter.api.BeforeEach; | |
import org.junit.jupiter.api.Test; | |
import org.junit.jupiter.api.extension.ExtendWith; | |
import org.mockito.Mock; | |
import org.mockito.junit.jupiter.MockitoExtension; | |
import static org.junit.jupiter.api.Assertions.*; | |
import static org.mockito.BDDMockito.willThrow; | |
import static org.mockito.Mockito.verify; | |
@ExtendWith(MockitoExtension.class) | |
class BootstrapTest { | |
private Bootstrap bootstrap; | |
@Mock | |
private InitializationService initializationService; | |
@BeforeEach | |
public void setUp() { | |
bootstrap = new Bootstrap(initializationService); | |
} | |
@Test | |
public void testInitMethodInvokeInitializationService() { | |
// given a bootstrap and its initialization service | |
assertNotNull(bootstrap); | |
// when the init method is triggered | |
bootstrap.init(); | |
// then the initialization of projects is triggered on the initialization service | |
verify(initializationService).initProjects(); | |
} | |
@Test | |
public void testIniBootstrapMethodCatchRuntimeExceptionComingFromInitProjects() { | |
// given a bootstrap and its initialization service throwing an exception | |
willThrow(RuntimeException.class).given(initializationService).initProjects(); | |
// when the init method is triggered | |
bootstrap.init(); | |
// then no exception is thrown | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment