GithubHelp home page GithubHelp logo

Add support for TestNG about wiremock HOT 8 CLOSED

wiremock avatar wiremock commented on July 19, 2024
Add support for TestNG

from wiremock.

Comments (8)

 avatar commented on July 19, 2024 1

For a record, I was able to create a trait in Groovy, which just needs implementing.

trait HttpMock {
    WireMockServer wireMockServer
    WireMock wireMock

    @BeforeMethod
    void start(){
        wireMockServer = new WireMockServer(wireMockConfig().port(httpPort));
        wireMockServer.start();
        WireMock.configureFor("localhost", httpPort);
        wireMock = new WireMock("localhost", httpPort);
    }
    @AfterMethod
    void stop(){
        wireMockServer.stop();
    }
    abstract int getHttpPort()
}

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

Hi,

Would you consider contributing a patch for this?

Cheers,
Tom

from wiremock.

dragisak avatar dragisak commented on July 19, 2024

I' d like to. I can't guarantee. Depends on my free time.

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

It's actually fairly easy to use WireMock without any specific test framework support. WireMock's own acceptance tests mostly don't use the JUnit rule, instead just extending this class:
https://github.com/tomakehurst/wiremock/blob/master/src/test/java/com/github/tomakehurst/wiremock/AcceptanceTestBase.java

from wiremock.

dragisak avatar dragisak commented on July 19, 2024

Yes. I looked around a bit and it's easy to do with TestNG's @Before/AfterMethod

There is a project to add Junit-like rules to TestNG but I wouldn't add that dependency here.

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

OK, I'll close this one off.

from wiremock.

 avatar commented on July 19, 2024

@dragisak, could you share how you would do it? Would help others in the future.

from wiremock.

dragisak avatar dragisak commented on July 19, 2024

A blast from the past. :-)

It's been a couple of years since I last did TestNG. Completely forgot the context of my question here. Thanks for posting the solution !

from wiremock.

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.