@@ -28,14 +28,14 @@ def setUp(self):
2828 def test_representation (self ):
2929 self .assertEqual (str (self .framework ), 'AwesomeName(0 files)' )
3030
31- def test_compact_name_morethanfourcapitals (self ):
31+ def test_compact_name_more_than_four_capitals (self ):
3232 test_framework = Framework ('FrameworkWithMoreThanFourCapitals' )
3333 self .assertEqual ('FC' , test_framework .compact_name )
3434
35- def test_compact_name_lessthanfourcapitals (self ):
35+ def test_compact_name_less_than_four_capitals (self ):
3636 self .assertEqual ('AN' , self .framework .compact_name )
3737
38- def test_compact_name_nocapitals (self ):
38+ def test_compact_name_no_capitals (self ):
3939 test_framework = Framework ('nocapitals' )
4040 self .assertEqual ('n' , test_framework .compact_name )
4141
@@ -70,26 +70,30 @@ class MetricsTests(unittest.TestCase):
7070
7171 def setUp (self ):
7272 self ._generate_mocks ()
73+ self ._populate_imports ()
7374
7475 def _generate_mocks (self ):
7576 self .foundation_kit = Framework ('FoundationKit' )
7677 self .design_kit = Framework ('DesignKit' )
7778 self .app_layer = Framework ('ApplicationLayer' )
7879 self .rxswift = Framework ('RxSwift' )
80+ self .test_design_kit = Framework (name = 'DesignKitTests' , is_test_framework = True )
7981 self .awesome_dependency = Framework ('AwesomeDependency' )
82+ self .not_linked_framework = Framework ('External' )
8083 self .frameworks = [
8184 self .foundation_kit ,
8285 self .design_kit ,
83- self .app_layer
86+ self .app_layer ,
87+ self .test_design_kit
8488 ]
8589
86- def _populate_app_layer_imports (self ):
90+ def _populate_imports (self ):
8791 self .app_layer .append_import (self .design_kit )
8892 self .app_layer .append_import (self .design_kit )
8993 self .app_layer .append_import (self .foundation_kit )
94+ self .test_design_kit .append_import (self .design_kit )
9095
9196 def test_distance_main_sequence (self ):
92- self ._populate_app_layer_imports ()
9397 self .app_layer .data .number_of_concrete_data_structures = 7
9498 self .app_layer .data .number_of_interfaces = 2
9599
@@ -100,8 +104,10 @@ def test_distance_main_sequence(self):
100104 def test_instability_no_imports (self ):
101105 self .assertEqual (0 , Metrics .instability (self .foundation_kit , self .frameworks ))
102106
107+ def test_instability_not_linked_framework (self ):
108+ self .assertEqual (0 , Metrics .instability (self .not_linked_framework , self .frameworks ))
109+
103110 def test_instability_imports (self ):
104- self ._populate_app_layer_imports ()
105111 self .assertAlmostEqual (1.0 , Metrics .instability (self .app_layer , self .frameworks ))
106112
107113 def test_abstractness_no_concretes (self ):
@@ -112,12 +118,13 @@ def test_abstractness_concretes(self):
112118 self .foundation_kit .data .number_of_concrete_data_structures = 4
113119 self .assertEqual (2 , Metrics .abstractness (self .foundation_kit ))
114120
115- def test_fan_in (self ):
116- self ._populate_app_layer_imports ()
121+ def test_fan_in_test_frameworks (self ):
117122 self .assertEqual (2 , Metrics .fan_in (self .design_kit , self .frameworks ))
118123
124+ def test_fan_in_no_test_frameworks (self ):
125+ self .assertEqual (1 , Metrics .fan_in (self .foundation_kit , self .frameworks ))
126+
119127 def test_fan_out (self ):
120- self ._populate_app_layer_imports ()
121128 self .assertEqual (3 , Metrics .fan_out (self .app_layer ))
122129
123130 def test_external_dependencies (self ):
@@ -134,7 +141,6 @@ def test_external_dependencies(self):
134141 self .assertEqual (design_external_deps , [])
135142
136143 def test_internal_dependencies (self ):
137- self ._populate_app_layer_imports ()
138144 self .design_kit .append_import (self .foundation_kit )
139145
140146 expected_foundation_internal_deps = []
@@ -165,6 +171,24 @@ def test_poc_valid_loc_noc(self):
165171 def test_poc_invalid_loc_noc (self ):
166172 self .assertEqual (0 , Metrics .percentage_of_comments (loc = 0 , noc = 0 ))
167173
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+
168192 @property
169193 def __dummy_external_frameworks (self ):
170194 return [
0 commit comments