@@ -40,15 +40,19 @@ protected function configure()
4040 ->setDescription ("generation and execution of test(s) defined in xml " )
4141 ->addArgument (
4242 'name ' ,
43- InputArgument::REQUIRED | InputArgument::IS_ARRAY ,
43+ InputArgument::OPTIONAL | InputArgument::IS_ARRAY ,
4444 "name of tests to generate and execute "
4545 )->addOption (
4646 'skip-generate ' ,
4747 'k ' ,
4848 InputOption::VALUE_NONE ,
4949 "skip generation and execute existing test "
50+ )->addOption (
51+ 'tests ' ,
52+ 't ' ,
53+ InputOption::VALUE_REQUIRED ,
54+ 'A parameter accepting a JSON string or JSON file path used to determine the test configuration '
5055 );
51-
5256 parent ::configure ();
5357 }
5458
@@ -63,6 +67,7 @@ protected function configure()
6367 protected function execute (InputInterface $ input , OutputInterface $ output ): int
6468 {
6569 $ tests = $ input ->getArgument ('name ' );
70+ $ json = $ input ->getOption ('tests ' ); // for backward compatibility
6671 $ skipGeneration = $ input ->getOption ('skip-generate ' );
6772 $ force = $ input ->getOption ('force ' );
6873 $ remove = $ input ->getOption ('remove ' );
@@ -86,7 +91,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8691 $ allowSkipped
8792 );
8893
89- $ testConfiguration = $ this ->getTestAndSuiteConfiguration ($ tests );
94+ if ($ json !== null && is_file ($ json )) {
95+ $ testConfiguration = file_get_contents ($ json );
96+ }
97+
98+ if (!empty ($ tests )) {
99+ $ testConfiguration = $ this ->getTestAndSuiteConfiguration ($ tests );
100+ }
101+
102+ if ($ testConfiguration !== null && !json_decode ($ testConfiguration )) {
103+ // stop execution if we have failed to properly parse any json passed in by the user
104+ throw new TestFrameworkException ("JSON could not be parsed: " . json_last_error_msg ());
105+ }
90106
91107 $ generationErrorCode = 0 ;
92108
@@ -98,7 +114,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
98114 '--remove ' => $ remove ,
99115 '--debug ' => $ debug ,
100116 '--allow-skipped ' => $ allowSkipped ,
101- '-v ' => $ verbose
117+ '-v ' => $ verbose ,
118+ ''
102119 ];
103120 $ command ->run (new ArrayInput ($ args ), $ output );
104121
0 commit comments