From f7f2ed8d32057a565afd609108c92924cc5f2015 Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Wed, 11 Mar 2026 11:44:02 -0400 Subject: [PATCH] Testing and harness are complete --- TESTING.md | 19 ++++++- tests/integration/TestSharedLayout.asp | 69 ++++++++++++++++++++++++++ tests/run-tests.cmd | 21 ++++++++ tests/test-manifest.asp | 3 +- 4 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 tests/integration/TestSharedLayout.asp create mode 100644 tests/run-tests.cmd diff --git a/TESTING.md b/TESTING.md index f06d98a..c2f13aa 100644 --- a/TESTING.md +++ b/TESTING.md @@ -19,6 +19,7 @@ The `tests/` IIS application assumes the repository layout keeps `tests/`, `publ | Create | `tests/component/web.config` | Mirrored config for nested component pages that load config-aware code | | Create | `tests/integration/web.config` | Mirrored config for nested integration pages that load config-aware code | | Create | `tests/sync-webconfigs.vbs` | Utility script to mirror `tests/web.config` into nested test folders | +| Create | `tests/run-tests.cmd` | Windows helper to sync configs and open the test runner URL | | Create | `tests/bootstrap.asp` | Shared test bootstrap and runtime reset helpers | | Create | `tests/PlainRunnerTheme.asp` | Local runner theme that removes CDN dependence from the test UI | | Create | `tests/support/HttpCaptureHelpers.asp` | Shared HTTP capture helpers for rendered-page assertions | @@ -33,6 +34,7 @@ The `tests/` IIS application assumes the repository layout keeps `tests/`, `publ | Create | `tests/integration/TestRoutes.asp` | Route-helper/config integration coverage | | Create | `tests/integration/TestConfigSettings.asp` | Nested config and fallback behavior coverage | | Create | `tests/integration/TestRenderedOutput.asp` | Production-page output assertions through safe HTTP capture | +| Create | `tests/integration/TestSharedLayout.asp` | Shared header/footer/layout assertions against rendered production pages | | Reference | `public/web.config` | Source of mirrored config keys for the test app | | Reference | `core/helpers.asp` | Helper functions and config-loading behavior under test | | Reference | `core/mvc.asp` | Dispatcher behavior used by the smoke test | @@ -49,6 +51,7 @@ The `tests/` IIS application assumes the repository layout keeps `tests/`, `publ 6. If you change `tests/web.config`, run `cscript //nologo tests\sync-webconfigs.vbs` to refresh the nested copies used by the unit, component, and integration pages. 7. If your production app is not served from the same host root as the `tests/` app, set `ProductionAppBaseUrl` in `tests/web.config` and re-run the sync script so rendered-output tests know where to send HTTP requests. Example: `http://localhost/` for a root site, or `http://localhost/MyClassicApp/` for a virtual-directory app. +8. To sync configs and open the suite in one step on Windows, run `tests\run-tests.cmd` with an optional runner URL argument. Example layout: @@ -84,12 +87,25 @@ http://localhost/tests-dev/run-all.asp aspunit renders a UI in runner mode and loads each registered page with `?task=test` behind the scenes. +On Windows you can also use: + +```bat +tests\run-tests.cmd +``` + +Or with an explicit runner URL: + +```bat +tests\run-tests.cmd http://localhost:8085/run-all.asp +``` + ## Adding a New Test Page 1. Choose the right folder: - `tests/unit/` for deterministic helper or registry tests - `tests/component/` for direct controller/object tests with controlled setup - - `tests/integration/` for narrow runtime smoke coverage, config behavior, or rendered-page capture +- `tests/integration/` for narrow runtime smoke coverage, config behavior, or rendered-page capture + - shared layout assertions belong here too, because they verify rendered production responses rather than isolated helper behavior 2. Create a new `.asp` file that: - includes `../aspunit/Lib/ASPUnit.asp` - includes `../bootstrap.asp` @@ -120,6 +136,7 @@ aspunit renders a UI in runner mode and loads each registered page with `?task=t - Helper, registry, component, and integration suites all execute. - Route-helper/config integration assertions execute from the same isolated IIS app. - Rendered-page capture assertions can verify production HTML and status codes without polluting aspunit JSON responses. +- Shared layout assertions can verify navbar, asset links, titles, and footer script presence across production-rendered pages. - Re-running the suite produces stable results. - The production site under `public/` still exposes no test runner pages or test routes. diff --git a/tests/integration/TestSharedLayout.asp b/tests/integration/TestSharedLayout.asp new file mode 100644 index 0000000..b5645b6 --- /dev/null +++ b/tests/integration/TestSharedLayout.asp @@ -0,0 +1,69 @@ + + + + +<% +Call ASPUnit.AddModule( _ + ASPUnit.CreateModule( _ + "Shared Layout Render Tests", _ + Array( _ + ASPUnit.CreateTest("HomePageIncludesSharedHeaderAssets"), _ + ASPUnit.CreateTest("HomePageUsesControllerTitleInLayout"), _ + ASPUnit.CreateTest("NotFoundPageStillIncludesSharedLayoutChrome") _ + ), _ + ASPUnit.CreateLifeCycle("SetupSharedLayout", "TeardownSharedLayout") _ + ) _ +) + +Call ASPUnit.Run() + +Sub SetupSharedLayout() + Call ResetTestRuntime() +End Sub + +Sub TeardownSharedLayout() + Call ResetTestRuntime() +End Sub + +Function HomePageIncludesSharedHeaderAssets() + Dim responseData + Dim body + + Set responseData = FetchPage("/") + body = responseData.Item("body") + + Call ASPUnit.Ok((responseData.Item("status") = 200 And _ + InStr(body, "navbar-brand rk-navbar-brand") > 0 And _ + InStr(body, "/css/site.css") > 0 And _ + InStr(body, "bootstrap.bundle.min.js") > 0), _ + "Home page should include shared header and footer assets from the layout") + + Set responseData = Nothing +End Function + +Function HomePageUsesControllerTitleInLayout() + Dim responseData + Set responseData = FetchPage("/") + + Call ASPUnit.Ok((InStr(LCase(responseData.Item("body")), "home") > 0), _ + "Home page layout should render the controller title in the tag") + + Set responseData = Nothing +End Function + +Function NotFoundPageStillIncludesSharedLayoutChrome() + Dim responseData + Dim body + + Set responseData = FetchPage("/404") + body = responseData.Item("body") + + Call ASPUnit.Ok((responseData.Item("status") = 404 And _ + InStr(body, "404 - Page Not Found") > 0 And _ + InStr(body, "navbar-brand rk-navbar-brand") > 0 And _ + InStr(body, "bootstrap.bundle.min.js") > 0), _ + "404 page should still render inside the shared layout chrome") + + Set responseData = Nothing +End Function +%> diff --git a/tests/run-tests.cmd b/tests/run-tests.cmd new file mode 100644 index 0000000..9a692b4 --- /dev/null +++ b/tests/run-tests.cmd @@ -0,0 +1,21 @@ +@echo off +setlocal + +set "SCRIPT_DIR=%~dp0" +set "RUNNER_URL=%~1" + +if "%RUNNER_URL%"=="" set "RUNNER_URL=http://localhost/tests-dev/run-all.asp" + +echo Syncing mirrored test web.config files... +cscript //nologo "%SCRIPT_DIR%sync-webconfigs.vbs" +if errorlevel 1 ( + echo Failed to sync mirrored test web.config files. + exit /b 1 +) + +echo Opening test runner: %RUNNER_URL% +start "" "%RUNNER_URL%" + +echo. +echo If your tests app is served from a different URL, pass it as the first argument: +echo tests\run-tests.cmd http://localhost:8085/run-all.asp diff --git a/tests/test-manifest.asp b/tests/test-manifest.asp index dd70a75..fcededa 100644 --- a/tests/test-manifest.asp +++ b/tests/test-manifest.asp @@ -7,7 +7,8 @@ Sub RegisterTestPages() "integration/TestMvcDispatch.asp", _ "integration/TestRoutes.asp", _ "integration/TestConfigSettings.asp", _ - "integration/TestRenderedOutput.asp" _ + "integration/TestRenderedOutput.asp", _ + "integration/TestSharedLayout.asp" _ )) End Sub %>