diff --git a/TestRunner/Program.cs b/TestRunner/Program.cs index d010669c..d539bc23 100644 --- a/TestRunner/Program.cs +++ b/TestRunner/Program.cs @@ -44,45 +44,47 @@ static void Main(string[] args) { LoadAllTestAssemblies(); - if (args.Length == 0) + + while (args.Length == 0 || !m_TestMethods.ContainsKey(args[0])) { - Console.WriteLine("Please provide a filter for the methods you want to run. This can be either the name of the method or its namespace (after 'BH.Test')"); - return; + if (args.Length != 0) + Console.WriteLine("Cannot find any test matching " + args[0]); + + Console.WriteLine("Please provide a filter for the methods you want to run. This can be either the name of the method or its namespace (after 'BH.Test')."); + + Console.WriteLine($"Available methods to run are: {string.Join(", ", m_TestMethods.Keys)}"); + + args = Console.ReadLine().Split(' '); } string key = args[0]; - if (!m_TestMethods.ContainsKey(key)) - { - Console.WriteLine("Cannot find any test matching " + key); - } - else + + foreach (MethodInfo method in m_TestMethods[key]) { - foreach (MethodInfo method in m_TestMethods[key]) + try { - try + object[] parameters = new object[] { }; + if (method.GetParameters().Length == 1) { - object[] parameters = new object[] { }; - if (method.GetParameters().Length == 1) + if (args.Length == 2) { - if (args.Length == 2) - { - parameters = new object[] { System.Convert.ToBoolean(args[1]) }; - } - else if (method.GetParameters()[0].HasDefaultValue) - { - parameters = new object[] { method.GetParameters()[0].DefaultValue }; - } + parameters = new object[] { System.Convert.ToBoolean(args[1]) }; + } + else if (method.GetParameters()[0].HasDefaultValue) + { + parameters = new object[] { method.GetParameters()[0].DefaultValue }; } - TestResult result = method.Invoke(null, parameters) as TestResult; - Console.WriteLine(); - Console.Write(result.FullMessage()); - } - catch (Exception e) - { - Console.WriteLine($"Method {method.Name} failed to run:\n{e.Message}"); } + TestResult result = method.Invoke(null, parameters) as TestResult; + Console.WriteLine(); + Console.Write(result.FullMessage()); + } + catch (Exception e) + { + Console.WriteLine($"Method {method.Name} failed to run:\n{e.Message}"); } } + }