Browse Source

Testing and harness are complete

master
Daniel Covington 1 month ago
parent
commit
f7f2ed8d32
4 changed files with 110 additions and 2 deletions
  1. +18
    -1
      TESTING.md
  2. +69
    -0
      tests/integration/TestSharedLayout.asp
  3. +21
    -0
      tests/run-tests.cmd
  4. +2
    -1
      tests/test-manifest.asp

+ 18
- 1
TESTING.md View File

@@ -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/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/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/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/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/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 | | 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/TestRoutes.asp` | Route-helper/config integration coverage |
| Create | `tests/integration/TestConfigSettings.asp` | Nested config and fallback behavior 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/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 | `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/helpers.asp` | Helper functions and config-loading behavior under test |
| Reference | `core/mvc.asp` | Dispatcher behavior used by the smoke 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. 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. 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. 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: 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. 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 ## Adding a New Test Page


1. Choose the right folder: 1. Choose the right folder:
- `tests/unit/` for deterministic helper or registry tests - `tests/unit/` for deterministic helper or registry tests
- `tests/component/` for direct controller/object tests with controlled setup - `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: 2. Create a new `.asp` file that:
- includes `../aspunit/Lib/ASPUnit.asp` - includes `../aspunit/Lib/ASPUnit.asp`
- includes `../bootstrap.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. - Helper, registry, component, and integration suites all execute.
- Route-helper/config integration assertions execute from the same isolated IIS app. - 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. - 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. - Re-running the suite produces stable results.
- The production site under `public/` still exposes no test runner pages or test routes. - The production site under `public/` still exposes no test runner pages or test routes.




+ 69
- 0
tests/integration/TestSharedLayout.asp View File

@@ -0,0 +1,69 @@
<!-- #include file="../aspunit/Lib/ASPUnit.asp" -->
<!-- #include file="../bootstrap.asp" -->
<!-- #include file="../support/HttpCaptureHelpers.asp" -->

<%
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")), "<title>home</title>") > 0), _
"Home page layout should render the controller title in the <title> 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
%>

+ 21
- 0
tests/run-tests.cmd View File

@@ -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

+ 2
- 1
tests/test-manifest.asp View File

@@ -7,7 +7,8 @@ Sub RegisterTestPages()
"integration/TestMvcDispatch.asp", _ "integration/TestMvcDispatch.asp", _
"integration/TestRoutes.asp", _ "integration/TestRoutes.asp", _
"integration/TestConfigSettings.asp", _ "integration/TestConfigSettings.asp", _
"integration/TestRenderedOutput.asp" _
"integration/TestRenderedOutput.asp", _
"integration/TestSharedLayout.asp" _
)) ))
End Sub End Sub
%> %>

Loading…
Cancel
Save

Powered by TurnKey Linux.