1 package searls.jasmine.runner;
2
3 import static org.hamcrest.Matchers.*;
4 import static org.junit.Assert.*;
5 import static org.mockito.Matchers.*;
6 import static org.mockito.Mockito.*;
7
8 import java.io.IOException;
9 import java.io.InputStream;
10 import java.net.MalformedURLException;
11 import java.net.URL;
12
13 import org.junit.Test;
14 import org.junit.runner.RunWith;
15 import org.mockito.InjectMocks;
16 import org.mockito.Mock;
17 import org.mockito.runners.MockitoJUnitRunner;
18
19 import searls.jasmine.io.IOUtilsWrapper;
20 import searls.jasmine.model.JasmineResult;
21
22 import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
23
24 @RunWith(MockitoJUnitRunner.class)
25 public class SpecRunnerExecutorTest {
26
27 private static final String BUILD_CONCLUSION_JS_CONTENTS = "'kaka';";
28 private static final String BUILD_REPORT_JS_CONTENTS = "'pants';";
29
30 @InjectMocks private SpecRunnerExecutor sut = new SpecRunnerExecutor();
31 @Mock private IOUtilsWrapper ioUtilsWrapper;
32
33 @Test
34 public void shouldFindSpecsInResults() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
35 when(ioUtilsWrapper.toString(isA(InputStream.class))).thenReturn(BUILD_CONCLUSION_JS_CONTENTS,BUILD_REPORT_JS_CONTENTS);
36 URL resource = getClass().getResource("/example_nested_specrunner.html");
37 JasmineResult result = sut.execute(resource);
38
39 assertThat(result,is(not(nullValue())));
40 assertThat(result.getDescription(),containsString("kaka"));
41 assertThat(result.getDetails(),containsString("pants"));
42 assertThat(result.didPass(),is(false));
43 }
44
45
46 }