question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

False positive mutant in Angular controller

See original GitHub issue

I have this code in an Angular 1.x controller:

    $scope.showDetail = function (id) {
      $uibModal.open({
        templateUrl: 'views/ProductDetail.html',
        controller: 'ProductDetailsController',
        size: 'lg',
        resolve: {
          id: function () {
            return id
          }
        }
      })
    }

My original test simply did expect($uibModal.open).toHaveBeenCalled which lets this mutant survive: $scope.showDetail = function (id) {}.

Performing this mutation manually yields a failing test:

    Expected spy open to have been called with [ { templateUrl : 'views/ProductDetail.html', controller : 'ProductDetailsController', size : <jasmine.any(function String() {
        [native code]
    })>, resolve : { id : <jasmine.any(function Function() {
        [native code]
    })> } } ] but it was never called.

I even extended my test to be more specific about the expected modal dialog: expect($uibModal.open).toHaveBeenCalledWith({ templateUrl: 'views/ProductDetail.html', controller: 'ProductDetailsController', size: jasmine.any(String), resolve: { id: jasmine.any(Function) } })

The mutant $scope.showDetail = function (id) {} still survives. How is that possible?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
nicojscommented, Oct 4, 2016

@bkimminich we just released Stryker 0.4.4 with the fix. Can you confirm that this issue is now solved?

1reaction
nicojscommented, Oct 1, 2016

@simondel fix works like a charm! See PR #155. I added the unit test to prevent this regression in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

False positive mutant in Angular controller · Issue #151 - GitHub
When Stryker selects tests for a mutant, it looks at which tests cover the smallest statement surrounding the mutated code. We do it...
Read more >
Calling All Mutants: Mutation Testing with Stryker - Sparkbox
Mutation testing should be used after your coverage is satisfactory and you want to make sure your tests aren't susceptible to false positives....
Read more >
Mutation testing, a.k.a. the power of mutants | TSH.io
In this article, I'll tell you all about mutation testing in ... Believe it or not, but sometimes unit tests give “false positive”...
Read more >
Working with AngularJS via Optimizely | roboboogie Blog
Roboboogie discusses how to work with AngularJS via Optimizely without ... as it can easily produce false positives, leaving you erroneously ...
Read more >
Troubleshooting | Stryker Mutator
If you are using TypeScript, it may happen that StrykerJS generates a mutant that survives, but is not compilable by TypeScript. Example: In...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found