Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Added ways to configure tests suites + Add PanoramicTimeSec… #10

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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