Code Monkey home page Code Monkey logo

Comments (6)

dreamhead avatar dreamhead commented on July 18, 2024

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.

marcingrzejszczak avatar marcingrzejszczak commented on July 18, 2024

Remeber that you may have some issues related to manual stopping and started as described in this issue #51

from moco.

 avatar commented on July 18, 2024

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.

dreamhead avatar dreamhead commented on July 18, 2024

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.

dreamhead avatar dreamhead commented on July 18, 2024

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.

marcingrzejszczak avatar marcingrzejszczak commented on July 18, 2024

That will be really appreciated - we had to get to the internals of Moco to manually start/stop server

from moco.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.