@@ -112,7 +112,7 @@ public TestExplorerViewModel(IEventAggregator eventAggregator, IAutomationProjec
112
112
/// <summary>
113
113
/// Load the fixtures and test case from local storage
114
114
/// </summary>
115
- async Task LoadDataAsync ( )
115
+ async Task LoadFixturesAsync ( )
116
116
{
117
117
try
118
118
{
@@ -129,18 +129,6 @@ async Task LoadDataAsync()
129
129
}
130
130
TestFixtureViewModel testFixtureVM = new TestFixtureViewModel ( testFixture ) ;
131
131
this . TestFixtures . Add ( testFixtureVM ) ;
132
-
133
- foreach ( var testCaseDirectory in Directory . GetDirectories ( Path . Combine ( this . fileSystem . TestCaseRepository , testFixture . FixtureId ) ) )
134
- {
135
- var testCase = this . fileSystem . LoadFiles < TestCase > ( testCaseDirectory ) . Single ( ) ;
136
- if ( testCase . IsDeleted )
137
- {
138
- continue ;
139
- }
140
- TestCaseViewModel testCaseVM = new TestCaseViewModel ( testCase ) ;
141
- testFixtureVM . Tests . Add ( testCaseVM ) ;
142
- }
143
-
144
132
}
145
133
isInitialized = true ;
146
134
}
@@ -151,6 +139,27 @@ async Task LoadDataAsync()
151
139
}
152
140
}
153
141
142
+ void LoadTestCasesForFixture ( TestFixtureViewModel testFixtureViewModel )
143
+ {
144
+ try
145
+ {
146
+ foreach ( var testCaseDirectory in Directory . GetDirectories ( Path . Combine ( this . fileSystem . TestCaseRepository , testFixtureViewModel . FixtureId ) ) )
147
+ {
148
+ var testCase = this . fileSystem . LoadFiles < TestCase > ( testCaseDirectory ) . Single ( ) ;
149
+ if ( testCase . IsDeleted )
150
+ {
151
+ continue ;
152
+ }
153
+ TestCaseViewModel testCaseVM = new TestCaseViewModel ( testCase ) ;
154
+ testFixtureViewModel . Tests . Add ( testCaseVM ) ;
155
+ }
156
+ }
157
+ catch ( Exception ex )
158
+ {
159
+ logger . Error ( ex , "There was an error while trying to load test cases for fixture : {0}" , testFixtureViewModel . DisplayName ) ;
160
+ }
161
+ }
162
+
154
163
/// <summary>
155
164
/// Setup the collection view with grouping and sorting
156
165
/// </summary>
@@ -171,6 +180,14 @@ private void CreateDefaultView()
171
180
} ) ;
172
181
}
173
182
183
+ public void OnFixtureExpanded ( TestFixtureViewModel testFixtureViewModel )
184
+ {
185
+ if ( ! testFixtureViewModel . Tests . Any ( ) )
186
+ {
187
+ LoadTestCasesForFixture ( testFixtureViewModel ) ;
188
+ }
189
+ }
190
+
174
191
#endregion Constructor
175
192
176
193
#region Test Fixture
@@ -1155,7 +1172,10 @@ private async Task<bool> TryRunTestCaseAsync(TestCaseViewModel testCaseVM)
1155
1172
/// <returns></returns>
1156
1173
protected override async Task OnInitializeAsync ( CancellationToken cancellationToken )
1157
1174
{
1158
- await LoadDataAsync ( ) ;
1175
+ if ( ! isInitialized )
1176
+ {
1177
+ await LoadFixturesAsync ( ) ;
1178
+ }
1159
1179
await base . OnInitializeAsync ( cancellationToken ) ;
1160
1180
}
1161
1181
0 commit comments