@@ -40,15 +40,19 @@ protected function configure()
40
40
->setDescription ("generation and execution of test(s) defined in xml " )
41
41
->addArgument (
42
42
'name ' ,
43
- InputArgument::REQUIRED | InputArgument::IS_ARRAY ,
43
+ InputArgument::OPTIONAL | InputArgument::IS_ARRAY ,
44
44
"name of tests to generate and execute "
45
45
)->addOption (
46
46
'skip-generate ' ,
47
47
'k ' ,
48
48
InputOption::VALUE_NONE ,
49
49
"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 '
50
55
);
51
-
52
56
parent ::configure ();
53
57
}
54
58
@@ -63,6 +67,7 @@ protected function configure()
63
67
protected function execute (InputInterface $ input , OutputInterface $ output ): int
64
68
{
65
69
$ tests = $ input ->getArgument ('name ' );
70
+ $ json = $ input ->getOption ('tests ' ); // for backward compatibility
66
71
$ skipGeneration = $ input ->getOption ('skip-generate ' );
67
72
$ force = $ input ->getOption ('force ' );
68
73
$ remove = $ input ->getOption ('remove ' );
@@ -86,7 +91,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
86
91
$ allowSkipped
87
92
);
88
93
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
+ }
90
106
91
107
$ generationErrorCode = 0 ;
92
108
@@ -98,7 +114,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
98
114
'--remove ' => $ remove ,
99
115
'--debug ' => $ debug ,
100
116
'--allow-skipped ' => $ allowSkipped ,
101
- '-v ' => $ verbose
117
+ '-v ' => $ verbose ,
118
+ ''
102
119
];
103
120
$ command ->run (new ArrayInput ($ args ), $ output );
104
121
0 commit comments