Skip to content

Commit

Permalink
Merge pull request #10 from Muriel-Salvan/add_tests_suite_confs
Browse files Browse the repository at this point in the history
[Feature] Added ways to configure tests suites + Add PanoramicTimeSec…
  • Loading branch information
Muriel-Salvan authored Jan 18, 2021
2 parents 5f9716e + 3266263 commit 163a3e5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Data/Source/Scripts/AutoTest_Suite.psc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Scriptname AutoTest_Suite extends ReferenceAlias
string gTestType = "Unknown"
string gJSONRunFile = "AutoTest_Unknown_Run.json"
string gJSONStatusesFile = "AutoTest_Unknown_Statuses.json"
string gJSONconfigFile = "AutoTest_Unknown_Config.json"
bool gInsideTransaction = false

; Initialize the script
Expand Down Expand Up @@ -61,6 +62,7 @@ function SetTestType(string testType)
gTestType = testType
gJSONRunFile = "AutoTest_" + gTestType + "_Run.json"
gJSONStatusesFile = "AutoTest_" + gTestType + "_Statuses.json"
gJSONConfigFile = "AutoTest_" + gTestType + "_Config.json"
endFunction

; Get the test type
Expand Down Expand Up @@ -91,6 +93,16 @@ string function GetTestStatus(string testName)
return JsonUtil.GetStringValue(gJSONStatusesFile, testName)
endFunction

; Get a config value from the JSON config file
;
; Parameters::
; * *configName* (string): The config name
; Result::
; * string: The config value
string function GetConfig(string configName)
return JsonUtil.GetStringValue(gJSONConfigFile, configName)
endFunction

; Get the number of registered tests
;
; Result::
Expand Down
9 changes: 7 additions & 2 deletions Data/Source/Scripts/AutoTest_Suite_Locations.psc
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,17 @@ endFunction
; * *testName* (string): The test name to run
function RunTest(string testName)
string[] fields = StringUtil.Split(testName, "/")
string panoramicTimeSecsStr = GetConfig("PanoramicTimeSecs")
if panoramicTimeSecsStr == ""
panoramicTimeSecsStr = "5.0"
endIf
float panoramicTimeSecs = panoramicTimeSecsStr as float
if fields.Length == 3
; This is an exterior cell
TestCow(fields[0], fields[1] as int, fields[2] as int, 5.0)
TestCow(fields[0], fields[1] as int, fields[2] as int, panoramicTimeSecs)
else
; This is an interior cell
TestCoc(fields[0], 5.0)
TestCoc(fields[0], panoramicTimeSecs)
endIf
SetTestStatus(testName, "ok")
endFunction
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ Please refer to the different tests suites sections below to know which test nam

When AutoTest starts a tests session, it will run all the tests defined in a Run list, and skip the tests that already have a status `ok`.

#### The tests suites' Config files: `AutoTest_*_Config.json`

Each test suite has an optional JSON file storing its configuration, that could alter the way tests are being performed.
Configuration files are always organized as a set of key -> value string pairs.

Here is an example of such a configuration file content:
```json
{
"string": {
"config_option_1": "value_1",
"config_option_2": "value_2"
}
}
```

The meaning and values of each configuration option is specific to the tests suite. See below sections for details.

### The tests suites

Different tests suites allow for different kind of tests.
Expand Down Expand Up @@ -216,6 +233,9 @@ Example of Run file for this test, in `SKSE\Plugins\StorageUtilData\AutoTest_Loc

![Example of Locations test](https://raw.githubusercontent.com/Muriel-Salvan/AutoTest/master/docs/locations_example.gif)

The `Locations` tests can be configurable and accepts the following configuration options:
* `PanoramicTimeSecs`: Number of seconds (as a float in a string) taken by the test to make a quick panoramic turn around the player. Defaults to `"5.0"`.

### The in-game menu

A small menu is accessible from a test cell, to register some pre-defined tests and run them.
Expand Down

0 comments on commit 163a3e5

Please sign in to comment.