Skip to content

Some test cases fails on Windows OS #252

Description

@Boiarshinov

Hi! I had exploring XmlUnit and found out that some test cases fails in assertj and assertj3 modules.
Here is a test results: failed_tests_result.zip (generated by Intellij IDEA).

These tests fails because I run them on Windows machine and where is a difference between Linux and Windows line separators.
On Linux line separator is \n and on Windows is \r\n.

So I propose to change \n in regular expressions to \R for failed tests.
Example:

//before
thrown.expectAssertionErrorPattern("^\\nExpecting:\\n <.*" + Pattern.quote(TestResources.TEST_RESOURCE_DIR) + "invalidBook.xml>\\nto be valid but found following problems:\\n.*");

//after
thrown.expectAssertionErrorPattern("^\\RExpecting:\\R <.*" + Pattern.quote(TestResources.TEST_RESOURCE_DIR) + "invalidBook.xml>\\Rto be valid but found following problems:\\R.*");

\R - is a special option in regex world and have meaning "any linebreak in Unicode". It's a synonym to (?:\r\n?|\n|\x0B|\f|\x85). (Wiki source)

Also some tests fails because javax.xml.parsers.DocumentBuilder always parse \r\n as \n. But assertions validate against %n which is formatted to \r\n in Windows.
To fix this kind of tests I propose to change

//before
thrown.expectAssertionError("Expected text value 'x' but was '%nx '");

//after
thrown.expectAssertionError("Expected text value 'x' but was '\nx '");

I will create a PR ASAP.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions