forked from Kros-sk/TeaPie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCommand.cs
More file actions
69 lines (57 loc) · 3.43 KB
/
Copy pathTestCommand.cs
File metadata and controls
69 lines (57 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using Spectre.Console.Cli;
using System.ComponentModel;
using TeaPie.StructureExploration.Paths;
namespace TeaPie.DotnetTool;
internal sealed class TestCommand : ApplicationCommandBase<TestCommand.Settings>
{
protected override ApplicationBuilder ConfigureApplication(Settings settings)
{
var pathToLogFile = settings.LogFile ?? string.Empty;
var logLevel = Helper.ResolveLogLevel(settings);
var path = PathResolver.Resolve(settings.Path, Directory.GetCurrentDirectory());
var pathToRequestsLogFile = settings.RequestsLogFile ?? string.Empty;
var appBuilder = ApplicationBuilder.Create(path.IsCollectionPath());
appBuilder
.WithPath(path)
.WithTemporaryPath(settings.TemporaryPath ?? string.Empty)
.WithLogging(logLevel, pathToLogFile, settings.LogFileLogLevel, pathToRequestsLogFile, settings.UseTreeLogging)
.WithEnvironment(settings.Environment ?? string.Empty)
.WithEnvironmentFile(PathResolver.Resolve(settings.EnvironmentFilePath, string.Empty))
.WithReportFile(PathResolver.Resolve(settings.ReportFilePath, string.Empty))
.WithInitializationScript(PathResolver.Resolve(settings.InitializationScriptPath, string.Empty))
.WithVariablesCaching(!settings.NoVariablesCaching)
.WithDefaultPipeline();
return appBuilder;
}
public sealed class Settings : LoggingSettings
{
[CommandArgument(0, "[path]")]
[Description("Path to the collection, test case (.http) or single-file test case (.tp) which will be tested. Defaults to the current directory.")]
public string? Path { get; init; }
[CommandOption("--temp-path")]
[Description("Temporary path for the application. Defaults to the system's temporary folder with a TeaPie sub-folder " +
"if no path is provided.")]
public string? TemporaryPath { get; init; }
[CommandOption("-e|--env|--environment")]
[Description("Name of the environment on which application will be run.")]
public string? Environment { get; init; }
[CommandOption("--env-file|--environment-file")]
[Description("Path to file, which contains definitions of available environments. If not provided, " +
"the tool will use the first matching 'env.json' file found in '.teapie' folder or the collection " +
"(respectively parent folder of test case).")]
public string? EnvironmentFilePath { get; init; }
[CommandOption("-r|--report-file")]
[Description("Path to file, which will be used for test results summary report generation. " +
"If this option is not used, no report to file is generated.")]
public string? ReportFilePath { get; init; }
[CommandOption("-i|--init-script|--initialization-script")]
[Description("Path to script, which will be used for initialization before the first test-case execution. " +
"If not provided, the tool will use the first matching 'init.csx' file found in '.teapie' folder or the collection" +
" (respectively parent folder of test case).")]
public string? InitializationScriptPath { get; init; }
[CommandOption("--no-cache-vars|--no-cache-variables")]
[DefaultValue(false)]
[Description("Disables loading variables from file and caching them to file.")]
public bool NoVariablesCaching { get; init; }
}
}