From 32662635269269127f06462b5edef05daababa0e Mon Sep 17 00:00:00 2001 From: Muriel Salvan Date: Mon, 18 Jan 2021 15:22:21 +0100 Subject: [PATCH] [Feature] Added ways to configure tests suites + Add PanoramicTimeSecs option for Locations tests --- Data/Source/Scripts/AutoTest_Suite.psc | 12 +++++++++++ .../Scripts/AutoTest_Suite_Locations.psc | 9 +++++++-- README.md | 20 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Data/Source/Scripts/AutoTest_Suite.psc b/Data/Source/Scripts/AutoTest_Suite.psc index 6fb3927..9942038 100644 --- a/Data/Source/Scripts/AutoTest_Suite.psc +++ b/Data/Source/Scripts/AutoTest_Suite.psc @@ -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 @@ -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 @@ -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:: diff --git a/Data/Source/Scripts/AutoTest_Suite_Locations.psc b/Data/Source/Scripts/AutoTest_Suite_Locations.psc index 98fd4dc..1f61b99 100644 --- a/Data/Source/Scripts/AutoTest_Suite_Locations.psc +++ b/Data/Source/Scripts/AutoTest_Suite_Locations.psc @@ -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 diff --git a/README.md b/README.md index ac4d054..25d444c 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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.