Skip to content

Commit 9fbdd91

Browse files
committed
tests are updated
1 parent 27b0641 commit 9fbdd91

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

src/main/java/io/visual_regression_tracker/sdk_java/TestRunResult.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package io.visual_regression_tracker.sdk_java;
22

33
import io.visual_regression_tracker.sdk_java.response.TestRunResponse;
4-
import lombok.Builder;
54
import lombok.Getter;
65

76
@Getter
8-
@Builder
97
public class TestRunResult {
108
private final TestRunResponse testRunResponse;
119
private final String imageUrl;

src/test/java/io/visual_regression_tracker/sdk_java/VisualRegressionTrackerTest.java

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package io.visual_regression_tracker.sdk_java;
22

3-
import java.io.IOException;
4-
import java.util.Objects;
5-
63
import com.google.gson.Gson;
74
import io.visual_regression_tracker.sdk_java.request.BuildRequest;
85
import io.visual_regression_tracker.sdk_java.request.TestRunRequest;
@@ -24,16 +21,15 @@
2421
import org.testng.annotations.DataProvider;
2522
import org.testng.annotations.Test;
2623

24+
import java.io.IOException;
25+
import java.util.Objects;
26+
2727
import static org.hamcrest.CoreMatchers.containsString;
2828
import static org.hamcrest.CoreMatchers.is;
2929
import static org.hamcrest.MatcherAssert.assertThat;
3030
import static org.mockito.ArgumentMatchers.any;
3131
import static org.mockito.ArgumentMatchers.anyString;
32-
import static org.mockito.Mockito.doCallRealMethod;
33-
import static org.mockito.Mockito.mock;
34-
import static org.mockito.Mockito.reset;
35-
import static org.mockito.Mockito.verify;
36-
import static org.mockito.Mockito.when;
32+
import static org.mockito.Mockito.*;
3733

3834
public class VisualRegressionTrackerTest {
3935

@@ -67,6 +63,7 @@ public void setup() {
6763
this.config.setApiUrl(server.url("/").toString());
6864
vrt = new VisualRegressionTracker(config);
6965
vrtMocked = mock(VisualRegressionTracker.class);
66+
vrtMocked.paths = new PathProvider("baseApiUrl");
7067
}
7168

7269
@SneakyThrows
@@ -175,13 +172,19 @@ public Object[][] trackErrorCases() {
175172
{
176173
TestRunResponse.builder()
177174
.url("https://someurl.com/test/123123")
175+
.imageName("imageName")
176+
.baselineName("baselineName")
177+
.diffName("diffName")
178178
.status(TestRunStatus.UNRESOLVED)
179179
.build(),
180180
"Difference found: https://someurl.com/test/123123"
181181
},
182182
{
183183
TestRunResponse.builder()
184184
.url("https://someurl.com/test/123123")
185+
.imageName("imageName")
186+
.baselineName("baselineName")
187+
.diffName("diffName")
185188
.status(TestRunStatus.NEW)
186189
.build(),
187190
"No baseline: https://someurl.com/test/123123"
@@ -214,22 +217,37 @@ public void trackShouldLogSevere(TestRunResponse testRunResponse, String expecte
214217

215218
@DataProvider(name = "shouldTrackPassCases")
216219
public Object[][] shouldTrackPassCases() {
217-
return new Object[][] {
218-
{
219-
TestRunResponse.builder()
220-
.url("https://someurl.com/test/123123")
221-
.status(TestRunStatus.OK)
222-
.build(),
223-
}
220+
return new Object[][] {
221+
{
222+
TestRunResponse.builder()
223+
.id("someId")
224+
.imageName("imageName")
225+
.baselineName("baselineName")
226+
.diffName("diffName")
227+
.diffPercent(12.32f)
228+
.diffTollerancePercent(0.01f)
229+
.pixelMisMatchCount(1)
230+
.merge(false)
231+
.url("https://someurl.com/test/123123")
232+
.status(TestRunStatus.OK)
233+
.build(),
234+
}
224235
};
225236
}
226237

227238
@Test(dataProvider = "shouldTrackPassCases")
228239
public void shouldTrackPass(TestRunResponse testRunResponse) throws IOException {
229240
when(vrtMocked.submitTestRun(anyString(), anyString(), any())).thenReturn(testRunResponse);
241+
vrtMocked.paths = new PathProvider("backendUrl");
230242

231243
doCallRealMethod().when(vrtMocked).track(anyString(), anyString(), any());
232-
vrtMocked.track("name", "image", TestRunOptions.builder().build());
244+
TestRunResult testRunResult = vrtMocked.track("name", "image", TestRunOptions.builder().build());
245+
246+
assertThat(testRunResult.getTestRunResponse(), is(testRunResponse));
247+
assertThat(testRunResult.getUrl(), is(testRunResponse.getUrl()));
248+
assertThat(testRunResult.getImageUrl(), is("backendUrl/".concat(testRunResponse.getImageName())));
249+
assertThat(testRunResult.getDiffUrl(), is("backendUrl/".concat(testRunResponse.getDiffName())));
250+
assertThat(testRunResult.getBaselineUrl(), is("backendUrl/".concat(testRunResponse.getBaselineName())));
233251
}
234252

235253
@Test()

0 commit comments

Comments
 (0)