コード例 #1
0
        protected override bool OnCanRun(IExecutionHandler executionContext)
        {
            FilePath assemblyFileName = GetAssemblyFileName();

            if (assemblyFileName.IsNull)
            {
                return(false);
            }

            var command = new DotNetCoreExecutionCommand(
                assemblyFileName.ParentDirectory,
                assemblyFileName.FileName,
                string.Empty);

            return(executionContext.CanExecute(command));
        }
コード例 #2
0
        int StartCustomTestHost(TestProcessStartInfo startInfo, TestContext currentTestContext)
        {
            OperationConsole console = currentTestContext.ExecutionContext.ConsoleFactory.CreateConsole(
                OperationConsoleFactory.CreateConsoleOptions.Default.WithTitle(GettextCatalog.GetString("Unit Tests")));

            var command = new DotNetCoreExecutionCommand(
                startInfo.WorkingDirectory,
                startInfo.FileName,
                startInfo.Arguments
                );

            command.Command = startInfo.FileName;
            command.EnvironmentVariables = startInfo.EnvironmentVariables;

            debugOperation = currentTestContext.ExecutionContext.ExecutionHandler.Execute(command, console);

            // Returns the IDE process id which is incorrect. This should be the
            // custom test host process. The VSCodeDebuggerSession does not return
            // the correct process id. If it did the process is not available
            // immediately since it takes some time for it to start so a wait
            // would be needed here.
            return(Process.GetCurrentProcess().Id);
        }
コード例 #3
0
        int StartCustomTestHost(TestProcessStartInfo startInfo, TestContext currentTestContext)
        {
            OperationConsole console = currentTestContext.ExecutionContext.ConsoleFactory.CreateConsole(
                OperationConsoleFactory.CreateConsoleOptions.Default.WithTitle(GettextCatalog.GetString("Unit Tests")));

            var command = new DotNetCoreExecutionCommand(
                startInfo.WorkingDirectory,
                startInfo.FileName,
                startInfo.Arguments
                );

            command.Command              = startInfo.FileName;
            command.Arguments            = startInfo.Arguments;
            command.EnvironmentVariables = startInfo.EnvironmentVariables;

            debugOperation = currentTestContext.ExecutionContext.ExecutionHandler.Execute(command, console);

            // Returns the IDE process id which is incorrect. This should be the
            // custom test host process. The VSCodeDebuggerSession does not return
            // the correct process id. If it did the process is not available
            // immediately since it takes some time for it to start so a wait
            // would be needed here. Note that returning process id of 1 for .NET
            // Core SDK versions 1.0 does not work the debugger never starts.
            var latestVersion = DotNetCoreSdk.Versions.FirstOrDefault();

            if (latestVersion == null || latestVersion.Major < 2)
            {
                return(Process.GetCurrentProcess().Id);
            }

            //This is horrible hack...
            //VSTest wants us to send it PID of process our debugger just started so it can kill it when tests are finished
            //VSCode debug protocol doesn't give us PID of debugee
            //But we must give VSTest valid PID or it won't work... In past we gave it IDE PID, but with new versions of
            //VSTest it means it will kill our IDE... Hence give it PID 1 and hope it won't kill it.
            return(1);
        }