False positive mutant in Angular controller
See original GitHub issueI 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:
- Created 7 years ago
- Comments:13 (9 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bkimminich we just released Stryker 0.4.4 with the fix. Can you confirm that this issue is now solved?
@simondel fix works like a charm! See PR #155. I added the unit test to prevent this regression in the future.