예제 #1
0
        public Executor(IExecutorConfiguration configuration)
        {
            Throw.If.Object.IsNull(configuration, nameof(configuration));

            Configuration = configuration;

            Factory.Instance.Create(out ITestResultEndPoint results);
            Results = results;

            _headerContent.Add(@" _   _               _                    _____           _   ");
            _headerContent.Add(@"| \ | | _   _   ___ | |  ___   __ _  _ __|_   _|___  ___ | |_ ");
            _headerContent.Add(@"|  \| || | | | / __|| | / _ \ / _` || '__| | | / _ \/ __|| __|");
            _headerContent.Add(@"| |\  || |_| || (__ | ||  __/| (_| || | _  | ||  __/\__ \| |_ ");
            _headerContent.Add(@"|_| \_| \__,_| \___||_| \___| \__,_||_|(_) |_| \___||___/ \__|");
            _headerContent.Add(@"  ____                           _                            ");
            _headerContent.Add(@" / ___| ___   _ __   ___   ___  | |  ___                      ");
            _headerContent.Add(@"| |    / _ \ | '_ \ / __| / _ \ | | / _ \                     ");
            _headerContent.Add(@"| |___| (_) || | | |\__ \| (_) || ||  __/                     ");
            _headerContent.Add(@" \____|\___/ |_| |_||___/ \___/ |_| \___|                     ");
            _headerContent.Add(@"                                                              ");
        }
예제 #2
0
 public void Create(out IExecutor @object, IExecutorConfiguration configuration) => @object = new Executor(configuration);
예제 #3
0
 public void Create(out IExecutorConfiguration @object) => @object = new ExecutorConfiguration();
예제 #4
0
        internal static void Main(String[] args)
        {
            XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetEntryAssembly()), new FileInfo("log4net.config"));

            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            _arguments.Collect(args);

            Argument arg;

            if (_arguments.TryGetSwitch(HELP_SWITCH_S, out _) || _arguments.TryGetSwitch(HELP_SWITCH_L, out _))
            {
                PrintHelp();
                return;
            }

            if ((_arguments.TryGetSwitch(CONFIG_SWITCH_S, out arg) || _arguments.TryGetSwitch(CONFIG_SWITCH_L, out arg)) && arg.HasValue)
            {
                _log.Info($"Loading configuration from {arg.Value.Format()}.");

                if (Configuration.TryLoad(arg.Value, out _configuration))
                {
                    _log.Info($"Configuration loaded from {arg.Value.Format()}.");
                }
            }

            if (_configuration == null)
            {
                _log.Info($"Loading configuration from {Configuration.DefaultFilePath.Format()}.");

                if (Configuration.TryLoad(out _configuration))
                {
                    _log.Info($"Configuration loaded from {Configuration.DefaultFilePath.Format()}.");
                }
                else
                {
                    _log.Info("Using default configuration.");
                    _configuration = Configuration.Default;
                    _configuration.Save();
                }
            }

            if ((_arguments.TryGetSwitch(FILE_SWITCH_S, out arg) || _arguments.TryGetSwitch(FILE_SWITCH_L, out arg)) && arg.HasValue)
            {
                if (File.Exists(arg.Value))
                {
                    _assemblies = new FileInfo[] { new FileInfo(arg.Value) };
                }
                else
                {
                    _log.Error($"Could not find assembly at path {arg.Value.Format()}");
                }
            }
            else
            {
                if ((_arguments.TryGetSwitch(DIR_SWITCH_S, out arg) || _arguments.TryGetSwitch(DIR_SWITCH_L, out arg)) && arg.HasValue)
                {
                    _configuration.Locator.SearchDirectory = arg.Value;
                }

                _assemblies = new AssemblyLocator()
                {
                    SearchDirectory       = new DirectoryInfo(Environment.ExpandEnvironmentVariables(_configuration.Locator.SearchDirectory)),
                    SearchDepth           = _configuration.Locator.SearchDepth,
                    SearchPattern         = _configuration.Locator.SearchPattern,
                    IgnoredDirectoryNames = _configuration.Locator.IgnoredDirectoryNames
                }.DiscoverAssemblies();
            }

            IExecutorConfiguration configuration = _configuration.Dump();

            configuration.Assemblies = _assemblies;
            Factory.Instance.Create(out IExecutor executor, configuration);
            executor.Execute();

            Factory.Instance.Create(out IConsoleWriter writer, _configuration.Executor.Verbosity, ColorScheme.Default);
            writer.Load(executor.Results);
            writer.Write();

            if (executor.Configuration.WriteReport)
            {
                Factory.Instance.Create(out IJsonWriter jsonWriter, new FileInfo($"Execution_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.json"));
                jsonWriter.Load(executor.Results);
                jsonWriter.Write();
            }

            WaitOnDebug();

            Environment.ExitCode = (Int32)(executor.Results.GetResults().HasFails() ? ExitCode.Fail : ExitCode.OK);
        }