Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some test cases fails on Windows OS #252

Closed
Boiarshinov opened this issue Mar 10, 2022 · 1 comment
Closed

Some test cases fails on Windows OS #252

Boiarshinov opened this issue Mar 10, 2022 · 1 comment
Labels
Milestone

Comments

@Boiarshinov
Copy link
Contributor

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.

@bodewig
Copy link
Member

bodewig commented Mar 15, 2022

resolved via #253

@bodewig bodewig closed this as completed Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants