Open johnny1952 opened 7 years ago
根据示例修改后的demo代码: package com.cibfintech.cfttest.httptest;
import org.apache.http.client.fluent.Content; import org.apache.http.client.fluent.Request; import org.junit.After; import org.junit.Before; import org.junit.Test;
import com.github.dreamhead.moco.HttpServer;
import java.io.IOException;
import static com.github.dreamhead.moco.Moco.httpServer; import static com.github.dreamhead.moco.Runner.runner; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat;
public class DemoMoco { private com.github.dreamhead.moco.Runner runner1;
@Before
public void setup() {
HttpServer server = httpServer(12306);
server.response("foo");
runner1 = runner(server);
runner1.start();
}
@After
public void tearDown() {
runner1.stop();
}
@Test
public void should_response_as_expected() throws IOException {
Content content = Request.Get("http://localhost:12306").execute().returnContent();
assertThat(content.asString(), is("foo"));
}
}
https://github.com/dreamhead/moco/blob/master/moco-doc/usage.md#runner-api上的代码有编译错误。 但如果按下面这样修改就不会有错误: private com.github.dreamhead.moco.Runner runner; 请确认。谢谢。