@@ -252,36 +252,50 @@ public class $pluginClass: NSObject, FlutterPlugin {
252252 // build files.
253253 await build (buildTarget, validateNativeBuildProject: false );
254254
255- if (buildTarget == 'ios' ) {
256- await testWithNewIOSSimulator ('TestNativeUnitTests' , (String deviceId) async {
255+ switch (buildTarget) {
256+ case 'apk' :
257+ if (await exec (
258+ path.join ('.' , 'gradlew' ),
259+ < String > ['testDebugUnitTest' ],
260+ workingDirectory: path.join (rootPath, 'android' ),
261+ canFail: true ,
262+ ) != 0 ) {
263+ throw TaskResult .failure ('Platform unit tests failed' );
264+ }
265+ break ;
266+ case 'ios' :
267+ await testWithNewIOSSimulator ('TestNativeUnitTests' , (String deviceId) async {
268+ if (! await runXcodeTests (
269+ platformDirectory: path.join (rootPath, 'ios' ),
270+ destination: 'id=$deviceId ' ,
271+ configuration: 'Debug' ,
272+ testName: 'native_plugin_unit_tests_ios' ,
273+ skipCodesign: true ,
274+ )) {
275+ throw TaskResult .failure ('Platform unit tests failed' );
276+ }
277+ });
278+ break ;
279+ case 'macos' :
257280 if (! await runXcodeTests (
258- platformDirectory: path.join (rootPath, 'ios ' ),
259- destination: 'id=$ deviceId ' ,
281+ platformDirectory: path.join (rootPath, 'macos ' ),
282+ destination: 'platform=macOS ' ,
260283 configuration: 'Debug' ,
261- testName: 'native_plugin_unit_tests_ios ' ,
284+ testName: 'native_plugin_unit_tests_macos ' ,
262285 skipCodesign: true ,
263286 )) {
264287 throw TaskResult .failure ('Platform unit tests failed' );
265288 }
266- });
267- } else if (buildTarget == 'macos' ) {
268- if (! await runXcodeTests (
269- platformDirectory: path.join (rootPath, 'macos' ),
270- destination: 'platform=macOS' ,
271- configuration: 'Debug' ,
272- testName: 'native_plugin_unit_tests_macos' ,
273- skipCodesign: true ,
274- )) {
275- throw TaskResult .failure ('Platform unit tests failed' );
276- }
277- } else if (buildTarget == 'windows' ) {
278- if (await exec (
279- path.join (rootPath, 'build' , 'windows' , 'plugins' , 'plugintest' , 'Release' , 'plugintest_plugin_test' ),
280- < String > [],
281- canFail: true ,
282- ) != 0 ) {
283- throw TaskResult .failure ('Platform unit tests failed' );
284- }
289+ break ;
290+ case 'windows' :
291+ if (await exec (
292+ path.join (rootPath, 'build' , 'windows' , 'plugins' , 'plugintest' , 'Release' , 'plugintest_plugin_test' ),
293+ < String > [],
294+ canFail: true ,
295+ ) != 0 ) {
296+ throw TaskResult .failure ('Platform unit tests failed' );
297+ }
298+ break ;
285299 }
286300 }
287301
0 commit comments