@@ -43,21 +43,36 @@ struct PackageManifestEdits: SyntaxCodeActionProvider {
43
43
}
44
44
45
45
do {
46
- // Describe the target we are going to create.
47
- let target = try TargetDescription (
48
- name: " \( targetName) Tests " ,
49
- dependencies: [ . byName( name: targetName, condition: nil ) ] ,
50
- type: . test
51
- )
46
+ var actions : [ CodeAction ] = [ ]
52
47
53
- let edits = try AddTarget . addTarget ( target, to: scope. file)
54
- return [
55
- CodeAction (
56
- title: " Add test target " ,
57
- kind: . refactor,
58
- edit: edits. asWorkspaceEdit ( snapshot: scope. snapshot)
59
- )
48
+ let variants : [ ( AddTarget . TestHarness , String ) ] = [
49
+ ( . swiftTesting, " Swift Testing " ) ,
50
+ ( . xctest, " XCTest " ) ,
60
51
]
52
+ for (testingLibrary, libraryName) in variants {
53
+ // Describe the target we are going to create.
54
+ let target = try TargetDescription (
55
+ name: " \( targetName) Tests " ,
56
+ dependencies: [ . byName( name: targetName, condition: nil ) ] ,
57
+ type: . test
58
+ )
59
+
60
+ let edits = try AddTarget . addTarget (
61
+ target,
62
+ to: scope. file,
63
+ configuration: . init( testHarness: testingLibrary)
64
+ )
65
+
66
+ actions. append (
67
+ CodeAction (
68
+ title: " Add test target ( \( libraryName) ) " ,
69
+ kind: . refactor,
70
+ edit: edits. asWorkspaceEdit ( snapshot: scope. snapshot)
71
+ )
72
+ )
73
+ }
74
+
75
+ return actions
61
76
} catch {
62
77
return [ ]
63
78
}
0 commit comments