From b359f52ae903d6aed47cd01cd955390bf3a88331 Mon Sep 17 00:00:00 2001 From: cmelendez Date: Thu, 21 Sep 2023 17:44:08 -0400 Subject: [PATCH] Added non-strict-mode that allows runs even with failing tests --- .../MutationTestingAnalysis.class.st | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/MuTalk-Model/MutationTestingAnalysis.class.st b/src/MuTalk-Model/MutationTestingAnalysis.class.st index 926f55ec..acd91ec3 100644 --- a/src/MuTalk-Model/MutationTestingAnalysis.class.st +++ b/src/MuTalk-Model/MutationTestingAnalysis.class.st @@ -11,7 +11,8 @@ Class { 'mutations', 'testCases', 'coverageAnalysisResult', - 'logger' + 'logger', + 'beStrictMode' ], #category : #'MuTalk-Model' } @@ -180,6 +181,12 @@ MutationTestingAnalysis class >> testCasesReferencesFrom: testClass [ in: testClass ] ] +{ #category : #accessing } +MutationTestingAnalysis >> beStrictMode: aBoolean [ + + beStrictMode := aBoolean +] + { #category : #accesing } MutationTestingAnalysis >> coverageAnalysisResult [ @@ -231,7 +238,30 @@ MutationTestingAnalysis >> initialTestRun [ "Do an initial run of the tests to check that they are all green. Only green tests count for the mutation testing analysis" - testCases do: [ :aTestCase | aTestCase runChecked ] + [ testCases do: [ :aTestCase | aTestCase runChecked ] ] + on: TestsWithErrorsException + do: [ :ex | + beStrictMode + ifTrue: [ ^ ex pass ] + ifFalse: [self initialTestRunNonStricMode ]. + ex return: true ] +] + +{ #category : #running } +MutationTestingAnalysis >> initialTestRunNonStricMode [ + "In case that beStricMode is false, it will filter the passed tests" + + | initialTestCases countFailingTests | + initialTestCases := testCases size. + + self testCases: (testCases select: [ :aTestCase | + aTestCase testCase run runCount + = aTestCase testCase run passedCount ]). + + countFailingTests := initialTestCases - testCases size. + countFailingTests > 0 ifTrue: [ + self inform: 'Your have ' , countFailingTests printString , + ' test(s) that have Errors or Failures. But in Non-Strict-Mode I will filter them' ] ] { #category : #'initialize-release' } @@ -243,7 +273,8 @@ MutationTestingAnalysis >> initializeFor: someTestCasesReferences mutating: some mutantsEvaluationStrategy := aMutantsEvaluationStrategy. particularResults := OrderedCollection new. elapsedTime := 0. - logger := aLogger + logger := aLogger. + beStrictMode := true. ] { #category : #accesing }