@@ -21,6 +21,8 @@ import com.fasterxml.jackson.databind.ObjectMapper
2121import org.apache.jmeter.junit.JMeterTestCase
2222import org.apache.jmeter.util.JMeterUtils
2323import org.junit.jupiter.api.Assertions.assertEquals
24+ import org.junit.jupiter.api.Assertions.assertFalse
25+ import org.junit.jupiter.api.Assertions.assertTrue
2426import org.junit.jupiter.api.Test
2527import org.junit.jupiter.api.fail
2628import org.junit.jupiter.api.io.TempDir
@@ -36,6 +38,22 @@ class HtmlReportGeneratorTest : JMeterTestCase() {
3638
3739 data class CheckArgumentsCase (val csvPath : String , val userPropertiesPath : String , val outputDirectoryPath : String , val expected : List <String >)
3840
41+ /* *
42+ * Assert that a file exists at the given path relative to a base directory
43+ */
44+ private fun assertFileExists (baseDir : File , relativePath : String , message : String? = null) {
45+ val file = File (baseDir, relativePath)
46+ assertTrue(file.exists()) { message ? : " $relativePath should exist" }
47+ }
48+
49+ /* *
50+ * Assert that a file does NOT exist at the given path relative to a base directory
51+ */
52+ private fun assertFileNotExists (baseDir : File , relativePath : String , message : String? = null) {
53+ val file = File (baseDir, relativePath)
54+ assertFalse(file.exists()) { message ? : " $relativePath should NOT exist" }
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