Skip to content

Wrongly switched actual and expected in equalsDart matcher #935

@mqus

Description

@mqus

If you test/run the following snippet:

import 'package:test/test.dart';
import 'package:code_builder/code_builder.dart';

void main() {
  test('test equalsDart',() {
    const actual = Code("final x='x';");
    expect(actual, equalsDart("final x='y';"));
});
}

The following error will be generated:

Expected: final x='y';
  Actual: StaticCode:<final x='x';>
   Which: final x='x';is different.
          Expected: final x='x';
            Actual: final x='y';
                             ^
           Differ at offset 9

Please notice the switch up of Expected and Actual on the fourth and fifth lines, which should be referring to the same actual and expected as the first and second line. actual should be referring to the first parameter of expect and not the content of the matcher, since the parameter is also named actual and all other matchers confirm to that spec.

This wrong message gets confusing fast, especially when testing larger code generation output where the exact mismatch location is harder to find.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions