@@ -89,11 +89,6 @@ public function parseSuiteDataIntoObjects($parsedSuiteData)
89
89
$ includeTests = $ this ->extractTestObjectsFromSuiteRef ($ groupTestsToInclude );
90
90
$ excludeTests = $ this ->extractTestObjectsFromSuiteRef ($ groupTestsToExclude );
91
91
92
- // add all test if include tests is completely empty
93
- if (empty ($ includeTests )) {
94
- $ includeTests = TestObjectHandler::getInstance ()->getAllObjects ();
95
- }
96
-
97
92
// parse any object hooks
98
93
if (array_key_exists (TestObjectExtractor::TEST_BEFORE_HOOK , $ parsedSuite )) {
99
94
$ suiteHooks [TestObjectExtractor::TEST_BEFORE_HOOK ] = $ testHookObjectExtractor ->extractHook (
@@ -109,12 +104,31 @@ public function parseSuiteDataIntoObjects($parsedSuiteData)
109
104
$ parsedSuite [TestObjectExtractor::TEST_AFTER_HOOK ]
110
105
);
111
106
}
107
+
112
108
if (count ($ suiteHooks ) == 1 ) {
113
109
throw new XmlException (sprintf (
114
110
"Suites that contain hooks must contain both a 'before' and an 'after' hook. Suite: \"%s \"" ,
115
111
$ parsedSuite [self ::NAME ]
116
112
));
117
113
}
114
+ // check if suite hooks are empty/not included and there are no included tests/groups/modules
115
+ $ noHooks = count ($ suiteHooks ) == 0 ||
116
+ (
117
+ empty ($ suiteHooks ['before ' ]->getActions ()) &&
118
+ empty ($ suiteHooks ['after ' ]->getActions ())
119
+ );
120
+ // if suite body is empty throw error
121
+ if ($ noHooks && empty ($ includeTests ) && empty ($ excludeTests )) {
122
+ throw new XmlException (sprintf (
123
+ "Suites must not be empty. Suite: \"%s \"" ,
124
+ $ parsedSuite [self ::NAME ]
125
+ ));
126
+ }
127
+
128
+ // add all test if include tests is completely empty
129
+ if (empty ($ includeTests )) {
130
+ $ includeTests = TestObjectHandler::getInstance ()->getAllObjects ();
131
+ }
118
132
119
133
// create the new suite object
120
134
$ suiteObjects [$ parsedSuite [self ::NAME ]] = new SuiteObject (
0 commit comments