Skip to content

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

Closed
@erikvanroon

Description

@erikvanroon

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.

Activity

PhilippSalvisberg

PhilippSalvisberg commented on Jan 6, 2022

@PhilippSalvisberg
Member

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

PhilippSalvisberg commented on Jan 6, 2022

@PhilippSalvisberg
Member

Implementation note:

added this to the v1.4.0 milestone on Jan 6, 2022
added a commit that references this issue on Jan 6, 2022

fixes #140 - Do not suppress multiple consecutive spaces

dde8e11
added a commit that references this issue on Jan 6, 2022

Merge pull request #141 from utPLSQL/bugfix/issue-140-preserve-ws

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @PhilippSalvisberg@erikvanroon

      Issue actions

        Multiple spaces are replaced by single spaces in failure message · Issue #140 · utPLSQL/utPLSQL-SQLDeveloper