1616import org .hamcrest .CoreMatchers ;
1717import org .hamcrest .MatcherAssert ;
1818import org .mockito .Mockito ;
19+ import org .simplify4u .sjf4jmock .LoggerMock ;
20+ import org .slf4j .Logger ;
1921import org .testng .annotations .AfterMethod ;
2022import org .testng .annotations .BeforeMethod ;
2123import org .testng .annotations .DataProvider ;
@@ -30,14 +32,17 @@ public class VisualRegressionTrackerTest {
3032 "http://localhost" ,
3133 "733c148e-ef70-4e6d-9ae5-ab22263697cc" ,
3234 "XHGDZDFD3GMJDNM87JKEMP0JS1G5" ,
33- "develop"
35+ "develop" ,
36+ false
3437 );
3538 private MockWebServer server ;
3639 private VisualRegressionTracker vrt ;
3740
3841 @ SneakyThrows
3942 @ BeforeMethod
4043 public void setup () {
44+ LoggerMock .clearInvocations ();
45+
4146 server = new MockWebServer ();
4247 server .start ();
4348
@@ -164,8 +169,8 @@ public void submitTestRunShouldThrowIfNotStarted() throws IOException {
164169 MatcherAssert .assertThat (exceptionMessage , CoreMatchers .is ("Visual Regression Tracker has not been started" ));
165170 }
166171
167- @ DataProvider (name = "trackShouldThrowExceptionCases " )
168- public Object [][] trackShouldThrowExceptionCases () {
172+ @ DataProvider (name = "trackErrorCases " )
173+ public Object [][] trackErrorCases () {
169174 return new Object [][]{
170175 {
171176 TestRunResponse .builder ()
@@ -184,9 +189,10 @@ public Object[][] trackShouldThrowExceptionCases() {
184189 };
185190 }
186191
187- @ Test (dataProvider = "trackShouldThrowExceptionCases " )
192+ @ Test (dataProvider = "trackErrorCases " )
188193 public void trackShouldThrowException (TestRunResponse testRunResponse , String expectedExceptionMessage ) throws IOException {
189194 VisualRegressionTracker vrtMocked = Mockito .mock (VisualRegressionTracker .class );
195+ vrtMocked .visualRegressionTrackerConfig = new VisualRegressionTrackerConfig ("" , "" , "" , "" , false );
190196 Mockito .when (vrtMocked .submitTestRun (Mockito .anyString (), Mockito .anyString (), Mockito .any ())).thenReturn (testRunResponse );
191197
192198 Mockito .doCallRealMethod ().when (vrtMocked ).track (Mockito .anyString (), Mockito .anyString (), Mockito .any ());
@@ -199,6 +205,19 @@ public void trackShouldThrowException(TestRunResponse testRunResponse, String ex
199205 MatcherAssert .assertThat (exceptionMessage , CoreMatchers .is (expectedExceptionMessage ));
200206 }
201207
208+ @ Test (dataProvider = "trackErrorCases" )
209+ public void trackShouldLogSevere (TestRunResponse testRunResponse , String expectedExceptionMessage ) throws IOException {
210+ Logger loggerMock = LoggerMock .getLoggerMock (VisualRegressionTracker .class );
211+ VisualRegressionTracker vrtMocked = Mockito .mock (VisualRegressionTracker .class );
212+ vrtMocked .visualRegressionTrackerConfig = new VisualRegressionTrackerConfig ("" , "" , "" , "" , true );
213+ Mockito .when (vrtMocked .submitTestRun (Mockito .anyString (), Mockito .anyString (), Mockito .any ())).thenReturn (testRunResponse );
214+
215+ Mockito .doCallRealMethod ().when (vrtMocked ).track (Mockito .anyString (), Mockito .anyString (), Mockito .any ());
216+ vrtMocked .track ("name" , "image" , TestRunOptions .builder ().build ());
217+
218+ Mockito .verify (loggerMock ).error (expectedExceptionMessage );
219+ }
220+
202221 @ DataProvider (name = "shouldTrackPassCases" )
203222 public Object [][] shouldTrackPassCases () {
204223 return new Object [][]{
0 commit comments