Giter Site home page Giter Site logo

Comments (4)

StefH avatar StefH commented on June 7, 2024 1

The functionality is like:

constructor

When creating a matcher using the constructor, and the pattern is invalid, an exception is thrown immediately.
Like:

    [Fact]
    public void JsonMatcher_WithInvalidStringValue_Should_ThrowException()
    {
        // Act
        // ReSharper disable once ObjectCreationAsStatement
        Action action = () => new JsonMatcher(MatchBehaviour.AcceptOnMatch, "{ \"Id\"");

        // Assert
        action.Should().Throw<JsonException>();
    }

    // or this
    [Fact]
    public void GraphQLMatcher_For_InvalidSchema_ThrowsGraphQLSyntaxErrorException()
    {
        // Act
        // ReSharper disable once ObjectCreationAsStatement
        Action action = () => _ = new GraphQLMatcher("in va lid");

        // Assert
        action.Should().Throw<GraphQLSyntaxErrorException>();
    }

during matching

When the input value for the matcher to match on, is invalid, the exception is remembered and returned in the result.
Like:

    [Fact]
    public void GraphQLMatcher_For_ValidSchema_And_IncorrectQueryWithError_WithThrowExceptionTrue_ReturnsError()
    {
        // Arrange
        var input = "{\"query\":\"{\\r\\n studentsX {\\r\\n fullName\\r\\n X\\r\\n }\\r\\n}\"}";

        // Act
        var matcher = new GraphQLMatcher(TestSchema);
        var result = matcher.IsMatch(input);

        // Assert
        result.Score.Should().Be(MatchScores.Mismatch);
        result.Exception!.Message.Should().StartWith("Cannot query field 'studentsX' on type 'Query'");
    }

In the high level mapping matcher code, this error/exception is logged and this mapping is skipped because it contains errors.

Does this help you, you did you actually use it in a different way ?
Because I do not understand this:

it would make my tests fail if an URL changed or a new URL was called by my code not yet covered by my tests

from wiremock.net.

JasonLandbridge avatar JasonLandbridge commented on June 7, 2024 1

Thank you very much for this answer! I will try it out when I have the chance. I will close this for now

from wiremock.net.

StefH avatar StefH commented on June 7, 2024

@JasonLandbridge
Sorry, this was indeed a small breaking change introduced in #986 in version 1.5.36 (21 September 2023).

This property was removed, and now you get logging in case the matcher fails.

from wiremock.net.

JasonLandbridge avatar JasonLandbridge commented on June 7, 2024

@StefH Thanks for tracking this down! I actually loved this option as it would make my tests fail if an URL changed or a new URL was called by my code not yet covered by my tests. But now, I assume, the tests can still pass due to the lack of a thrown exception if this happens.

Any chance this option can be returned or is there something similar available?

Cheers!

from wiremock.net.

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.