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

Multiple spaces are replaced by single spaces in failure message #140

Closed
erikvanroon opened this issue Jan 6, 2022 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@erikvanroon
Copy link

When the actual or expected value has multiple consecutive spaces and the test fails, the message on the failures tab shows both values with all multi-spaces replaced by a single one.
(See test script below)

This is annoying because at first I couldn't figure out why a test was failing because the message showed identical strings for actual and expected.
Running the test from SQLcl showed that actual had an extra space which isn't visible in feedback from the plugin.

Test Suite to reproduce

create or replace package ut_spaces
authid definer
is
    -- %suite(Test Plugin Output)

    -- %context(Multiple spaces in values)

        -- %test(Multiple spaces in actual)
        procedure multi_space_actual;

        -- %test(Multiple spaces in expect)
        procedure multi_space_expect;

    -- %endcontext

end ut_spaces;
/

create or replace package body ut_spaces
is

    -- Multiple spaces in actual
    procedure multi_space_actual
    is
        l_expect   varchar2(100);
        l_actual   varchar2(100);
    begin
        l_expect := 'This line has spaces';
        l_actual := 'This          line          has          spaces';

        ut.expect(l_actual).to_equal(l_expect);
    end;


    -- Multiple spaces in expect
    procedure multi_space_expect
    is
        l_expect   varchar2(100);
        l_actual   varchar2(100);
    begin
        l_expect := 'This          line          has          spaces';
        l_actual := 'This line has spaces';

        ut.expect(l_actual).to_equal(l_expect);
    end;

end ut_spaces;
/

In SQL Developer plugin
Running hese tests the plugin will report on the Failures tab:

Actual: 'This line has spaces' (varchar2) was expected to equal: 'This line has spaces' (varchar2)
at "ERO.UT_SPACES.MULTI_SPACE_ACTUAL", line 13 ut.expect(l_actual).to_equal(l_expect);

Note how all multiple spaces have been replaced by single spaces.

In SQLcl

Running the tests in SQLcl does show the multiple spaces
ERO@EVROCS>exec ut.run ('ut_spaces')
Test Plugin Output
  Multiple spaces in values
    Multiple spaces in actual [,481 sec] (FAILED - 1)
    Multiple spaces in expect [,004 sec] (FAILED - 2)

Failures:

  1) multi_space_actual
      Actual: 'This          line          has          spaces' (varchar2) was expected to equal: 'This line has spaces' (varchar2)
      at "ERO.UT_SPACES.MULTI_SPACE_ACTUAL", line 13 ut.expect(l_actual).to_equal(l_expect);

  2) multi_space_expect
      Actual: 'This line has spaces' (varchar2) was expected to equal: 'This          line          has          spaces' (varchar2)
      at "ERO.UT_SPACES.MULTI_SPACE_EXPECT", line 26 ut.expect(l_actual).to_equal(l_expect);

Finished in ,487971 seconds
2 tests, 2 failed, 0 errored, 0 disabled, 0 warning(s)


PL/SQL procedure successfully completed.
@PhilippSalvisberg
Copy link
Member

PhilippSalvisberg commented Jan 6, 2022

Thanks @erikvanroon for reporting this issue. I can reproduce it easily with your test case.

I'm using HTML to handle links in the field. So the content looks in my case as follows (PLSCOPE instead of ERO schema):

<html>
	<head>
		<style type="text/css">
			body, p {font-family: Dialog; font-size: 1.0em; line-height: 1.1em; margin-top: 0px; margin-bottom: 0px;}
		</style>
	</head>
	<body>
		<p>Actual: &#39;This          line          has          spaces&#39; (varchar2) was expected to equal: &#39;This line has spaces&#39; (varchar2)</p>
<p>at <a href="UNKNOWN/PLSCOPE/UT_SPACES/13">&quot;PLSCOPE.UT_SPACES.MULTI_SPACE_ACTUAL&quot;, line 13</a> ut.expect(l_actual).to_equal(l_expect);</p>

	</body>
</html>

This HTML code does not preserve whitespace. That's a bug.

@PhilippSalvisberg
Copy link
Member

PhilippSalvisberg commented Jan 6, 2022

Implementation note:

@PhilippSalvisberg PhilippSalvisberg added this to the v1.4.0 milestone Jan 6, 2022
PhilippSalvisberg added a commit that referenced this issue Jan 6, 2022
Bugfix #140 - Do not suppress multiple consecutive spaces
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