@@ -36,6 +36,24 @@ class HtmlReportGeneratorTest : JMeterTestCase() {
3636
3737 data class CheckArgumentsCase (val csvPath : String , val userPropertiesPath : String , val outputDirectoryPath : String , val expected : List <String >)
3838
39+ /* *
40+ * Assert that a file exists at the given path relative to a base directory
41+ */
42+ private fun assertFileExists (baseDir : File , relativePath : String , message : String? = null) {
43+ val file = File (baseDir, relativePath)
44+ val errorMessage = message ? : " $relativePath should exist"
45+ assert (file.exists()) { errorMessage }
46+ }
47+
48+ /* *
49+ * Assert that a file does NOT exist at the given path relative to a base directory
50+ */
51+ private fun assertFileNotExists (baseDir : File , relativePath : String , message : String? = null) {
52+ val file = File (baseDir, relativePath)
53+ val errorMessage = message ? : " $relativePath should NOT exist"
54+ assert (! file.exists()) { errorMessage }
55+ }
56+
3957 companion object {
4058 /* *
4159 * Combine the given path parts to one path with the correct path separator of the current platform.
@@ -141,4 +159,42 @@ class HtmlReportGeneratorTest : JMeterTestCase() {
141159 fail(" First result message should contain '$expectedError ', but was '$firstMessage '" )
142160 }
143161 }
162+
163+ @Test
164+ fun `report generation creates correct directory structure for HTML and JS files` () {
165+ val htmlReportGenerator = HtmlReportGenerator (
166+ combine(" testfiles" , " HTMLReportTestFile.csv" ),
167+ combine(" user.properties" ),
168+ testDirectory.toString()
169+ )
170+ htmlReportGenerator.run ()
171+
172+ // Verify directory structure exists
173+ assertFileExists(testDirectory, " content" )
174+ assertFileExists(testDirectory, " content/pages" )
175+ assertFileExists(testDirectory, " content/js" )
176+
177+ // Verify HTML pages are in correct location (content/pages/)
178+ assertFileExists(testDirectory, " content/pages/OverTime.html" )
179+ assertFileExists(testDirectory, " content/pages/ResponseTimes.html" )
180+ assertFileExists(testDirectory, " content/pages/Throughput.html" )
181+ assertFileExists(testDirectory, " content/pages/CustomsGraphs.html" )
182+
183+ // Verify JavaScript files are in correct location (content/js/)
184+ assertFileExists(testDirectory, " content/js/dashboard.js" )
185+ assertFileExists(testDirectory, " content/js/graph.js" )
186+ assertFileExists(testDirectory, " content/js/dashboard-commons.js" )
187+ assertFileExists(testDirectory, " content/js/customGraph.js" )
188+
189+ // Verify files are NOT at root level (catches the bug!)
190+ assertFileNotExists(testDirectory, " OverTime.html" , " OverTime.html should NOT be at root level" )
191+ assertFileNotExists(testDirectory, " ResponseTimes.html" , " ResponseTimes.html should NOT be at root level" )
192+ assertFileNotExists(testDirectory, " Throughput.html" , " Throughput.html should NOT be at root level" )
193+ assertFileNotExists(testDirectory, " CustomsGraphs.html" , " CustomsGraphs.html should NOT be at root level" )
194+ assertFileNotExists(testDirectory, " dashboard.js" , " dashboard.js should NOT be at root level" )
195+ assertFileNotExists(testDirectory, " graph.js" , " graph.js should NOT be at root level" )
196+
197+ // Verify index.html is at root (this should be correct)
198+ assertFileExists(testDirectory, " index.html" , " index.html should exist at root level" )
199+ }
144200}
0 commit comments