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