Comments (6)
I guess you want to run start()/stop() in setup/teardown method. From current code, you can access it directly. But I'm not sure if it is a good way to do that. Maybe I can moved some classes to public interface, so you can invoke it directly.
Could you please provide more details about your scenario?
from moco.
Remeber that you may have some issues related to manual stopping and started as described in this issue #51
from moco.
Because Moco is only one of the simulator, i still have many other simulators or other preparatioin code to run, so i don't like it fully fixed my testing code structure like this:
@Test
public void should_response_as_expected() throws Exception {
HttpServer server = httpserver(12306);
server.response("foo");
running(server, new Runnable() {
@Override
public void run() throws IOException {
Content content = Request.Get("http://localhost:12306").execute().returnContent();
assertThat(content.asString(), is("foo"));
}
});
}
i wold like to call Moco in @before or @BeforeClass or @rule or one helper class.
from moco.
Good point!
But it is not a good idea to simply give MocoHttpServer, the real server, to API, because it takes ActualHttpServer as argument.
Do you think if it is a good idea to run like the following?
ServerRunner runner = runner(server);
runner.start();
runner.stop();
from moco.
Code has been committed. You can refer to MocoRunnerTest.
Basically, in setup:
runner = runner(server);
runner.start();
in tearDown:
runner.stop();
Any feedback is welcome.
from moco.
That will be really appreciated - we had to get to the internals of Moco to manually start/stop server
from moco.
Related Issues (20)
- how to get different response for one api HOT 2
- When the response of a field value singular for Chinese characters, to return to the last character of the code
- 如何调整standalone的可接受大小 HOT 3
- 如何获取URI中的子串值作为返回报文 HOT 2
- moco怎么模拟入参为定长报文,出参同样返回定长报文 HOT 1
- maven run test with moco jsonHttpServer throw java.lang.RuntimeException: java.lang.IllegalArgumentException: unknown configuration :[Z@767df8bd HOT 1
- 怎么拿到请求中的remote_addr值?
- 部分中文和符号会出现乱码 HOT 3
- socket挡板当并发数较高时,出现了no buffer space available HOT 3
- default if json.req.prop not available HOT 1
- MOCO如何实现带参重定向 HOT 1
- socket请求实现多文件配置
- java.lang.IllegalArgumentException: unknown configuration
- Maven test fails to run moco server when using jacoco maven plugin 0.7.8 or newer #258
- Use URI path parameters on the response template HOT 6
- 返回值类型不支持xml HOT 2
- java.lang.IllegalArgumentException: unknown configuration :[Z@78073c4 HOT 2
- 请求参数中存在中文时,每次请求都报400,怎么进行解决? HOT 1
- 响应体中存在奇数个汉字的时候必定乱码 HOT 5
- 如何支持或的逻辑,以及如何支持对字段名采用正则匹配
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moco.