Skip to content

Support negative tests that expect errors (in MF2 tests) #242

@echeran

Description

@echeran
Collaborator

About half of the tests for MessageFormat 2 that are being sourced from the MFWG repo are negative tests -- they expect an error to occur. If we don't support that already, we should.

After ensuring that we can run such tests, then we should enable all of these tests in the ICU4J message_fmt2 executor.

Activity

added this to the 2024 Q3 ⟨P1⟩ milestone on Jun 23, 2024
sffc

sffc commented on Jun 24, 2024

@sffc
Member

Expected errors should, I think, be handled in the schema. This is what we do for example with likely subtags errors. In other words, the executor should return successfully when encountering an expected formatting error, and the test output should indicate in the schema somehow that an error had occurred.

In MessageFormat specifically, this is probably desirable, because both the fallback string and the error can occur at the same time, and they can therefore both be tested.

sven-oly

sven-oly commented on Sep 20, 2024

@sven-oly
Collaborator

Right now we have verification data for MF2 that indicates "expErrors" with at least one parameter "type", e.g., label "00021". This tells me that executing this test is expected to return an error of the given type.

{"label": "00021", "exp": "{|horse|}", "expErrors": [{"type": "bad-operand"}], "verify": "{|horse|}" }

Here's what ICU4C returns for this test:
{"label": "00021", "error": "formatToString", "error_detail": "U_MF_OPERAND_MISMATCH_ERROR"},
Note that there's no key "result".

ICU4J gives this output:
{"label": "00021", "result": "{|horse|}"}
Note that there is a key "result", but no "error" and no "error_detail" keys.

I think that ICU4C should indicate "Pass" because an error was returned, but should be "Fail" in the Java version. Neither should be reported as a "Error".

Note that the schema for the test output should allow optional "error" and "error_detail" fields. At this time, however, the schema for message format is apparently not being checked.

sffc

sffc commented on Sep 24, 2024

@sffc
Member

I see 2 ways of thinking about "expected errors", in red and blue:

image

We currently support only the red line: basically an unhandled exception, like a 500 server error.

My proposal was that we consider adding a new "result status" called a handled exception, which would be like a 406 "Not Acceptable" error: the executor understands the request, but it encountered an error case that it knows about and knows how to handle.

sffc

sffc commented on Mar 3, 2025

@sffc
Member

On 2024-10-28 we said: "Suggested path forward: make the result more structured."

Do we support structured test outputs in the framework?

echeran

echeran commented on Jun 24, 2025

@echeran
CollaboratorAuthor

This issue to support negative testing in Conformance also blocks us from supporting "rounding mode = unnecessary" in number formatting tests. See PR #468 for an example of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @echeran@sffc@sven-oly

        Issue actions

          Support negative tests that expect errors (in MF2 tests) · Issue #242 · unicode-org/conformance