@@ -5,18 +5,18 @@ import { TestRun, Uri } from 'vscode';
5
5
import * as typeMoq from 'typemoq' ;
6
6
import * as path from 'path' ;
7
7
import * as assert from 'assert' ;
8
- import { PytestTestDiscoveryAdapter } from '../../../../ client/testing/testController/pytest/pytestDiscoveryAdapter' ;
9
- import { ITestResultResolver , ITestServer } from '../../../../ client/testing/testController/common/types' ;
10
- import { PythonTestServer } from '../../../../ client/testing/testController/common/server' ;
11
- import { IPythonExecutionFactory } from '../../../../ client/common/process/types' ;
12
- import { ITestDebugLauncher } from '../../../../ client/testing/common/types' ;
13
- import { IConfigurationService , ITestOutputChannel } from '../../../../ client/common/types' ;
14
- import { IServiceContainer } from '../../../../ client/ioc/types' ;
15
- import { EXTENSION_ROOT_DIR_FOR_TESTS , initialize } from '../../../ initialize' ;
16
- import { traceLog } from '../ ../../../client/logging' ;
17
- import { PytestTestExecutionAdapter } from '../../../../ client/testing/testController/pytest/pytestExecutionAdapter' ;
18
- import { UnittestTestDiscoveryAdapter } from '../../../../ client/testing/testController/unittest/testDiscoveryAdapter' ;
19
- import { UnittestTestExecutionAdapter } from '../../../../ client/testing/testController/unittest/testExecutionAdapter' ;
8
+ import { PytestTestDiscoveryAdapter } from '../../../client/testing/testController/pytest/pytestDiscoveryAdapter' ;
9
+ import { ITestResultResolver , ITestServer } from '../../../client/testing/testController/common/types' ;
10
+ import { PythonTestServer } from '../../../client/testing/testController/common/server' ;
11
+ import { IPythonExecutionFactory } from '../../../client/common/process/types' ;
12
+ import { ITestDebugLauncher } from '../../../client/testing/common/types' ;
13
+ import { IConfigurationService , ITestOutputChannel } from '../../../client/common/types' ;
14
+ import { IServiceContainer } from '../../../client/ioc/types' ;
15
+ import { EXTENSION_ROOT_DIR_FOR_TESTS , initialize } from '../../initialize' ;
16
+ import { traceError , traceLog } from '../../../client/logging' ;
17
+ import { PytestTestExecutionAdapter } from '../../../client/testing/testController/pytest/pytestExecutionAdapter' ;
18
+ import { UnittestTestDiscoveryAdapter } from '../../../client/testing/testController/unittest/testDiscoveryAdapter' ;
19
+ import { UnittestTestExecutionAdapter } from '../../../client/testing/testController/unittest/testExecutionAdapter' ;
20
20
21
21
suite ( 'Functional Tests: test adapters' , ( ) => {
22
22
let resultResolver : typeMoq . IMock < ITestResultResolver > ;
@@ -74,18 +74,19 @@ suite('Functional Tests: test adapters', () => {
74
74
actualData = data ;
75
75
return Promise . resolve ( ) ;
76
76
} ) ;
77
+
78
+ // set workspace to test workspace folder and set up settings
79
+ workspaceUri = Uri . parse ( rootPathSmallWorkspace ) ;
77
80
configService . getSettings ( workspaceUri ) . testing . unittestArgs = [ '-s' , '.' , '-p' , '*test*.py' ] ;
78
- // run pytest discovery
81
+
82
+ // run unittest discovery
79
83
const discoveryAdapter = new UnittestTestDiscoveryAdapter (
80
84
pythonTestServer ,
81
85
configService ,
82
86
testOutputChannel ,
83
87
resultResolver . object ,
84
88
) ;
85
89
86
- // set workspace to test workspace folder
87
- workspaceUri = Uri . parse ( rootPathSmallWorkspace ) ;
88
-
89
90
await discoveryAdapter . discoverTests ( workspaceUri ) . finally ( ( ) => {
90
91
// verification after discovery is complete
91
92
resultResolver . verify (
@@ -117,18 +118,17 @@ suite('Functional Tests: test adapters', () => {
117
118
return Promise . resolve ( ) ;
118
119
} ) ;
119
120
121
+ // set settings to work for the given workspace
122
+ workspaceUri = Uri . parse ( rootPathLargeWorkspace ) ;
120
123
configService . getSettings ( workspaceUri ) . testing . unittestArgs = [ '-s' , '.' , '-p' , '*test*.py' ] ;
121
- // run pytest discovery
124
+ // run discovery
122
125
const discoveryAdapter = new UnittestTestDiscoveryAdapter (
123
126
pythonTestServer ,
124
127
configService ,
125
128
testOutputChannel ,
126
129
resultResolver . object ,
127
130
) ;
128
131
129
- // set workspace to test workspace folder
130
- workspaceUri = Uri . parse ( rootPathLargeWorkspace ) ;
131
-
132
132
await discoveryAdapter . discoverTests ( workspaceUri ) . finally ( ( ) => {
133
133
// verification after discovery is complete
134
134
resultResolver . verify (
@@ -242,7 +242,7 @@ suite('Functional Tests: test adapters', () => {
242
242
// set workspace to test workspace folder
243
243
workspaceUri = Uri . parse ( rootPathSmallWorkspace ) ;
244
244
configService . getSettings ( workspaceUri ) . testing . unittestArgs = [ '-s' , '.' , '-p' , '*test*.py' ] ;
245
- // run pytest execution
245
+ // run execution
246
246
const executionAdapter = new UnittestTestExecutionAdapter (
247
247
pythonTestServer ,
248
248
configService ,
@@ -261,17 +261,15 @@ suite('Functional Tests: test adapters', () => {
261
261
await executionAdapter
262
262
. runTests ( workspaceUri , [ 'test_simple.SimpleClass.test_simple_unit' ] , false , testRun . object )
263
263
. finally ( ( ) => {
264
- // verification after discovery is complete
264
+ // verification after execution is complete
265
265
resultResolver . verify (
266
266
( x ) => x . resolveExecution ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) ,
267
267
typeMoq . Times . once ( ) ,
268
268
) ;
269
269
270
270
// 1. Check the status is "success"
271
271
assert . strictEqual ( actualData . status , 'success' , "Expected status to be 'success'" ) ;
272
- // 2. Confirm no errors
273
- assert . strictEqual ( actualData . error , null , "Expected no errors in 'error' field" ) ;
274
- // 3. Confirm tests are found
272
+ // 2. Confirm tests are found
275
273
assert . ok ( actualData . result , 'Expected results to be present' ) ;
276
274
} ) ;
277
275
} ) ;
@@ -280,22 +278,25 @@ suite('Functional Tests: test adapters', () => {
280
278
resultResolver
281
279
. setup ( ( x ) => x . resolveExecution ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) )
282
280
. returns ( ( data ) => {
281
+ traceError ( `resolveExecution ${ data } ` ) ;
282
+ console . log ( `resolveExecution ${ data } ` ) ;
283
283
traceLog ( `resolveExecution ${ data } ` ) ;
284
284
// do the following asserts for each time resolveExecution is called, should be called once per test.
285
- // 1. Check the status is "success"
286
- assert . strictEqual ( data . status , 'success' , "Expected status to be 'success'" ) ;
287
- // 2. Confirm no errors
288
- assert . strictEqual ( data . error , null , "Expected no errors in 'error' field" ) ;
289
- // 3. Confirm tests are found
285
+ // 1. Check the status, can be subtest success or failure
286
+ assert (
287
+ data . status === 'subtest-success' || data . status === 'subtest-failure' ,
288
+ "Expected status to be 'subtest-success' or 'subtest-failure'" ,
289
+ ) ;
290
+ // 2. Confirm tests are found
290
291
assert . ok ( data . result , 'Expected results to be present' ) ;
291
292
return Promise . resolve ( ) ;
292
293
} ) ;
293
294
294
295
// set workspace to test workspace folder
295
- workspaceUri = Uri . parse ( rootPathSmallWorkspace ) ;
296
+ workspaceUri = Uri . parse ( rootPathLargeWorkspace ) ;
296
297
configService . getSettings ( workspaceUri ) . testing . unittestArgs = [ '-s' , '.' , '-p' , '*test*.py' ] ;
297
298
298
- // run pytest execution
299
+ // run unittest execution
299
300
const executionAdapter = new UnittestTestExecutionAdapter (
300
301
pythonTestServer ,
301
302
configService ,
@@ -311,14 +312,15 @@ suite('Functional Tests: test adapters', () => {
311
312
onCancellationRequested : ( ) => undefined ,
312
313
} as any ) ,
313
314
) ;
314
- // ['test_parameterized_subtest.NumbersTest.test_even'];
315
- await executionAdapter . runTests ( workspaceUri , [ ] , false , testRun . object ) . finally ( ( ) => {
316
- // verification after discovery is complete
317
- resultResolver . verify (
318
- ( x ) => x . resolveExecution ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) ,
319
- typeMoq . Times . exactly ( 200 ) ,
320
- ) ;
321
- } ) ;
315
+ await executionAdapter
316
+ . runTests ( workspaceUri , [ 'test_parameterized_subtest.NumbersTest.test_even' ] , false , testRun . object )
317
+ . finally ( ( ) => {
318
+ // verification after discovery is complete
319
+ resultResolver . verify (
320
+ ( x ) => x . resolveExecution ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) ,
321
+ typeMoq . Times . exactly ( 200 ) ,
322
+ ) ;
323
+ } ) ;
322
324
} ) ;
323
325
test ( 'pytest execution adapter small workspace' , async ( ) => {
324
326
// result resolver and saved data for assertions
@@ -397,9 +399,8 @@ suite('Functional Tests: test adapters', () => {
397
399
398
400
// generate list of test_ids
399
401
const testIds : string [ ] = [ ] ;
400
-
401
402
for ( let i = 0 ; i < 200 ; i = i + 1 ) {
402
- const testId = `${ rootPathLargeWorkspace } /test_parameterized .py::test_odd_even[${ i } ]` ;
403
+ const testId = `${ rootPathLargeWorkspace } /test_parameterized_subtest .py::test_odd_even[${ i } ]` ;
403
404
testIds . push ( testId ) ;
404
405
}
405
406
0 commit comments