For the result listeners, the file path for the result file is configured through the test automation ui. This is done when you add a new listener. Is there a way to modify this file path programatically? I have a plugin where I want to publish results, and set the file path through the plug in.
There are a couple of ways to do this depending on what you are trying to set the path to:
-
There are a few built in macros:
-
<Date>
ā Date and time the session was started -
<Name>
ā Operator Name (specified in Engine settings) -
<Station>
ā Operator Station (specified in Engine settings) -
<TestPlanName>
ā Test plan name -
<TestPlanDir>
ā Test plan folder
-
-
You can use existing Windows Environment Variables:
-
%USERNAME%
ā NT user name for the current user -
%STARTUP_DIR%
ā Fully qualified path to the folder from which the application was started (most useful when used from a console) -
%ENGINE_DIR%
ā Fully qualified path to the folder that contains the engine (also where most plugins are installed)
-
-
Use your plugin to create/set an environment variable:
Environment.SetEnvironmentVariable("Test1", "Value1");
From the UI, the user enters a file path in the red line, and the result listener is configured. I want to create a custom ui where I take the filepath as input, and then set that for the result listener. Even though the UI already does this, I want to see/modify this path.
Hmm, Iām not sure I completely follow, but in that UI, could you set the FilePath to %CustomResultPath% and then set that Environment Variable from without your plugin?
Unless you are going for a full custom UI, then you can access the ResultsSettings object to get to to all the connected Result Listeners. From there you can do something like this (there are for sure better ways to select the specific Result Listener, but just as an idea):
var resultListener = ResultSettings.Current.First(rl => rl.GetType().Equals(typeof(LogResultListener)));
(resultListener as LogResultListener).FilePath = new OpenTap.MacroString() { Text = @"C:\New File Path" };