Skip to content

Commit d748f83

Browse files
committed
Improved test coverage
1 parent bc546ab commit d748f83

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

swift_code_metrics/tests/test_metrics.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def _generate_mocks(self):
7979
self.rxswift = Framework('RxSwift')
8080
self.test_design_kit = Framework(name='DesignKitTests', is_test_framework=True)
8181
self.awesome_dependency = Framework('AwesomeDependency')
82+
self.not_linked_framework = Framework('External')
8283
self.frameworks = [
8384
self.foundation_kit,
8485
self.design_kit,
@@ -103,6 +104,9 @@ def test_distance_main_sequence(self):
103104
def test_instability_no_imports(self):
104105
self.assertEqual(0, Metrics.instability(self.foundation_kit, self.frameworks))
105106

107+
def test_instability_not_linked_framework(self):
108+
self.assertEqual(0, Metrics.instability(self.not_linked_framework, self.frameworks))
109+
106110
def test_instability_imports(self):
107111
self.assertAlmostEqual(1.0, Metrics.instability(self.app_layer, self.frameworks))
108112

@@ -167,6 +171,24 @@ def test_poc_valid_loc_noc(self):
167171
def test_poc_invalid_loc_noc(self):
168172
self.assertEqual(0, Metrics.percentage_of_comments(loc=0, noc=0))
169173

174+
def test_ia_analysis_zone_of_pain(self):
175+
self.assertTrue("Zone of Pain" in Metrics.ia_analysis(0.4, 0.4))
176+
177+
def test_ia_analysis_zone_of_uselessness(self):
178+
self.assertTrue("Zone of Uselessness" in Metrics.ia_analysis(0.7, 0.7))
179+
180+
def test_ia_analysis_highly_stable(self):
181+
self.assertTrue("Highly stable component" in Metrics.ia_analysis(0.1, 0.51))
182+
183+
def test_ia_analysis_highly_unstable(self):
184+
self.assertTrue("Highly unstable component" in Metrics.ia_analysis(0.81, 0.49))
185+
186+
def test_ia_analysis_low_abstract(self):
187+
self.assertTrue("Low abstract component" in Metrics.ia_analysis(0.51, 0.1))
188+
189+
def test_ia_analysis_high_abstract(self):
190+
self.assertTrue("High abstract component" in Metrics.ia_analysis(0.49, 0.81))
191+
170192
@property
171193
def __dummy_external_frameworks(self):
172194
return [

0 commit comments

Comments
 (0)