Skip to content

Commit 2244684

Browse files
committed
New test command line switch: --list
1 parent 097c8f3 commit 2244684

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

netmockery/CommandLineParser.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ static public class CommandLineParser
2020
private const string BOOL_SWITCH_NOTESTMODE = "--notestmode";
2121
private const string BOOL_SWITCH_STOP = "--stop";
2222
private const string BOOL_SWITCH_DIFF = "--diff";
23+
private const string BOOL_SWITCH_LIST = "--list";
2324

2425
static private string[] VALUE_SWITCHES = new[] { VALUE_SWITCH_URL, VALUE_SWITCH_ONLY };
25-
static private string[] BOOL_SWITCHES = new[] { BOOL_SWITCH_SHOWRESPONSE, BOOL_SWITCH_NOTESTMODE, BOOL_SWITCH_STOP, BOOL_SWITCH_DIFF };
26+
static private string[] BOOL_SWITCHES = new[] { BOOL_SWITCH_SHOWRESPONSE, BOOL_SWITCH_NOTESTMODE, BOOL_SWITCH_STOP, BOOL_SWITCH_DIFF, BOOL_SWITCH_LIST };
2627

2728
static private Dictionary<int, string[]> VALID_SWITHCES_BY_COMMAND = new Dictionary<int, string[]> {
2829
{ COMMAND_NORMAL, new[] { VALUE_SWITCH_URL, BOOL_SWITCH_NOTESTMODE } },
2930
{ COMMAND_SERVICE, new[] { VALUE_SWITCH_URL } },
30-
{ COMMAND_TEST, new[] { VALUE_SWITCH_URL, VALUE_SWITCH_ONLY, BOOL_SWITCH_SHOWRESPONSE, BOOL_SWITCH_STOP, BOOL_SWITCH_DIFF} },
31+
{ COMMAND_TEST, new[] { VALUE_SWITCH_URL, VALUE_SWITCH_ONLY, BOOL_SWITCH_SHOWRESPONSE, BOOL_SWITCH_STOP, BOOL_SWITCH_DIFF, BOOL_SWITCH_LIST} },
3132
{ COMMAND_DUMP, new string[0] }
3233
};
3334

@@ -135,7 +136,8 @@ static public ParsedCommandLine ParseArguments(string[] args)
135136
ShowResponse = boolValues[BOOL_SWITCH_SHOWRESPONSE],
136137
NoTestMode = boolValues[BOOL_SWITCH_NOTESTMODE],
137138
Stop = boolValues[BOOL_SWITCH_STOP],
138-
Diff = boolValues[BOOL_SWITCH_DIFF]
139+
Diff = boolValues[BOOL_SWITCH_DIFF],
140+
List = boolValues[BOOL_SWITCH_LIST]
139141
};
140142
}
141143
}
@@ -161,6 +163,7 @@ public class ParsedCommandLine
161163
public bool NoTestMode;
162164
public bool Stop;
163165
public bool Diff;
166+
public bool List;
164167

165168
public bool TestMode => !NoTestMode;
166169
}

netmockery/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ public static void Test(ParsedCommandLine commandArgs, EndpointCollection endpoi
173173
}
174174
}
175175
}
176+
else if (commandArgs.List)
177+
{
178+
testRunner.ListAllTestNames();
179+
}
176180
else
177181
{
178182
testRunner.TestAll(commandArgs.Stop, true);

netmockery/TestRunner.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ public void TestAll(bool stopAfterFirstFailure, bool outputCoverage)
7878
}
7979
}
8080

81+
public void ListAllTestNames()
82+
{
83+
var index = 0;
84+
foreach (var test in testcases)
85+
{
86+
WriteBeginTest(index++, test);
87+
WriteLine("");
88+
}
89+
}
90+
8191
public void WriteCoverage()
8292
{
8393
var ci = GetCoverageInfo();

0 commit comments

Comments
 (0)