1
0

Helios-SUnit-Tests.st 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. Smalltalk createPackage: 'Helios-SUnit-Tests'!
  2. TestCase subclass: #HLSUnitModelTest
  3. instanceVariableNames: 'model'
  4. package: 'Helios-SUnit-Tests'!
  5. !HLSUnitModelTest commentStamp!
  6. Test cases for the functionality of `HLSUnitModel`!
  7. !HLSUnitModelTest methodsFor: 'accessing'!
  8. thisPackage
  9. ^self class package
  10. ! !
  11. !HLSUnitModelTest methodsFor: 'initializing'!
  12. setUp
  13. super setUp.
  14. model := HLSUnitModel new
  15. ! !
  16. !HLSUnitModelTest methodsFor: 'tests'!
  17. testClassBecomesAvailable
  18. self assert: model testClasses isEmpty.
  19. model selectPackage: self thisPackage.
  20. self assert: (model testClasses includes: self class).
  21. !
  22. testEmptyTestResults
  23. self assert: (model testResult isKindOf: TestResult)
  24. !
  25. testInvertSelectedClasses
  26. model selectAllPackages.
  27. model selectAllClasses.
  28. model unselectClass: self class.
  29. self assert: model selectedClasses notEmpty.
  30. self assert: model selectedClasses size equals: model testClasses size - 1.
  31. model invertSelectedClasses.
  32. self assert: model selectedClasses size equals: 1.
  33. self assert: model selectedClasses anyOne equals: self class.
  34. !
  35. testInvertSelectedPackages
  36. model selectAllPackages.
  37. model unselectPackage: self thisPackage.
  38. self assert: model selectedPackages notEmpty.
  39. self assert: model selectedPackages size equals: model testPackages size - 1.
  40. model invertSelectedPackages.
  41. self assert: model selectedPackages size equals: 1.
  42. self assert: model selectedPackages anyOne equals: self thisPackage.
  43. !
  44. testSelectAllClasses
  45. model selectAllPackages.
  46. self assert: model testClasses notEmpty.
  47. model selectAllClasses.
  48. self assert: model selectedClasses size equals: model testClasses size
  49. !
  50. testSelectAllPackages
  51. self assert: model selectedPackages isEmpty.
  52. model selectAllPackages.
  53. self assert: model selectedPackages size equals: model testPackages size
  54. !
  55. testSelectClass
  56. | announcementFired |
  57. model selectPackage: self thisPackage.
  58. self assert: model selectedClasses isEmpty.
  59. model announcer on: HLClassSelected
  60. do: [ announcementFired := true ]
  61. for: self.
  62. model selectClass: self class.
  63. self assert: model selectedClasses anyOne equals: self class.
  64. self assert: announcementFired.
  65. !
  66. testSelectPackage
  67. | announcementFired |
  68. self assert: model selectedPackages isEmpty.
  69. model announcer on: HLPackageSelected
  70. do: [ announcementFired := true ]
  71. for: self.
  72. model selectPackage: self thisPackage.
  73. self assert: model selectedPackages anyOne equals: self thisPackage.
  74. self assert: announcementFired
  75. !
  76. testSelectedClassNotListedIfPackageUnselected
  77. model selectPackage: self thisPackage.
  78. model selectClass: self class.
  79. self assert: model selectedClasses anyOne equals: self class.
  80. model unselectPackage: self thisPackage.
  81. self assert: model selectedClasses isEmpty.
  82. !
  83. testTestClassHasOnlyTestClasses
  84. | notATestClass |
  85. notATestClass := Object subclass: #HLNotATestClass
  86. instanceVariableNames: ''
  87. package: self class category.
  88. model selectPackage: self thisPackage.
  89. self deny: (model testClasses includes: notATestClass).
  90. Smalltalk removeClass: notATestClass.
  91. !
  92. testTestPackages
  93. self assert: model testPackages notEmpty.
  94. self assert: (model testPackages anySatisfy: [:each | each = self thisPackage]).
  95. !
  96. testUnselectClass
  97. | announcementFired |
  98. model selectPackage: self thisPackage.
  99. model selectClass: self class.
  100. model announcer on: HLClassUnselected
  101. do: [ announcementFired := true ]
  102. for: self.
  103. model unselectClass: self class.
  104. self assert: model selectedClasses isEmpty.
  105. self assert: announcementFired
  106. !
  107. testUnselectPackage
  108. | announcementFired |
  109. model selectPackage: self thisPackage.
  110. model announcer on: HLPackageUnselected
  111. do: [ announcementFired := true ]
  112. for: self.
  113. model unselectPackage: self thisPackage.
  114. self assert: model selectedPackages isEmpty.
  115. self assert: announcementFired.
  116. ! !