Skip to content

Remove lines of codes, like method calls or List arguments #25

Description

@passsy

Thanks for creating this awesome tool! I used https://github.com/hcoles/pitest a lot in Java and I'm happy to see a similar tool for Dart. So far it is working, but the results are not very useful.

Remove method calls

The most common thing I detect with pitest is that method calls are not covered NonVoidMethodCallMutator. Look at this example:

void removeListener(void Function() listener) {
	_listeners.remove(listener);
}

I might call removeLister in my test, but I may not have a test that ensures the listener is removed from the internal list and won't fire anymore.

A mutation, removing the line would cover it:

void removeListener(void Function() listener) {
-   _listeners.remove(listener);
}

Remove list entries.

In my spot package, I create lists where each item is necessary. It would be beneficial to have a mutation that removes one entry.

  @useResult
  WidgetSelector<W> spot<W extends Widget>({
    List<WidgetSelector> parents = const [],
    List<WidgetSelector> children = const [],
  }) {
    final p = [if (self != null) self!, ...parents];
    final selector = WidgetSelector<W>(
      stages: [
        WidgetTypeFilter<W>(),
-       if (children.isNotEmpty) ChildFilter(children),
        if (p.isNotEmpty) ParentFilter(p),
      ],
    );
    return selector;
  }

Unfortunately, I think the XML Regex syntax is too limited for this kind of mutation. Do we maybe need a Dart API with granular control of the AST?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions