Skip to content

Commit

Permalink
add tests for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Durieux Pol committed Apr 15, 2024
1 parent 148dbf2 commit 937205b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/MuTalk-Model/MTAnalysis.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ MTAnalysis >> packagesToMutate: aCollectionOfPackages [
MTAnalysis >> percentile: aPercentage for: aCollection [

| size index |
aCollection isEmpty ifTrue: [ ^ nil ].
aCollection isEmpty ifTrue: [
^ CollectionIsEmpty signalWith: aCollection ].
size := aCollection size.
index := (aPercentage percent * size) rounded.
^ aCollection at: index
Expand All @@ -283,6 +284,7 @@ MTAnalysis >> run [

^ [
self initialTestRun.
"The budget is started after the initial test run because the default one needs the run time of tests"
self startBudget.
logger logAnalysisStartFor: self.
elapsedTime := [
Expand Down
33 changes: 33 additions & 0 deletions src/MuTalk-Tests/MTAnalysisTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,39 @@ MTAnalysisTest >> testDefaultParameters [
self assert: analysis defaultBudget species equals: MTTimeBudget
]

{ #category : 'tests' }
MTAnalysisTest >> testErrorWhenInitializingDefaultTestFilterBeforeInitialTestRun [

| analysis |
analysis := MTAnalysis new
classesToMutate: { MTAuxiliarClassForMTAnalysis };
testClasses: { MTAuxiliarClassForMTAnalysisTest }.

self should: [ analysis initializeTestFilter ] raise: Error
]

{ #category : 'tests' }
MTAnalysisTest >> testErrorWhenStartingDefaultBudgetBeforeInitialTestRun [

| analysis |
analysis := MTAnalysis new
classesToMutate: { MTAuxiliarClassForMTAnalysis };
testClasses: { MTAuxiliarClassForMTAnalysisTest }.

self should: [ analysis startBudget ] raise: Error
]

{ #category : 'tests' }
MTAnalysisTest >> testErrorWhenTryingToGetPercentileOfEmptyCollection [

| analysis |
analysis := MTAnalysis new.

self
should: [ analysis percentile: 1 for: { } ]
raise: Error
]

{ #category : 'testing' }
MTAnalysisTest >> testExecutingInfiniteLoopAnalysis [

Expand Down

0 comments on commit 937205b

Please sign in to comment.