Ejemplo n.º 1
0
        public void Test(IEnumerable <SolutionProject> testProjects = null)
        {
            if (testProjects == null)
            {
                testProjects = Projects.Where(p => p.Name.EndsWith(".Tests"));
            }

            foreach (SolutionProject project in testProjects)
            {
                NormalizedPath projectPath = project.Path.GetDirectory().FullPath;
                NormalizedPath binDir      = projectPath.AppendPart("bin").AppendPart(_globalInfo.BuildConfiguration);
                NormalizedPath objDir      = projectPath.AppendPart("obj");
                string         assetsJson  = File.ReadAllText(objDir.AppendPart("project.assets.json"));
                bool           isNunitLite = assetsJson.Contains("NUnitLite");
                bool           isVSTest    = assetsJson.Contains("Microsoft.NET.Test.Sdk");
                foreach (NormalizedPath buildDir in Directory.GetDirectories(binDir))
                {
                    string framework            = buildDir.LastPart;
                    string fileWithoutExtension = buildDir.AppendPart(project.Name);
                    string testBinariesPath     = "";
                    if (isNunitLite)
                    {
                        // Using NUnitLite.
                        testBinariesPath = fileWithoutExtension + ".exe";
                        if (File.Exists(testBinariesPath))
                        {
                            _globalInfo.Cake.Information($"Testing via NUnitLite ({framework}): {testBinariesPath}");
                            _globalInfo.Cake.NUnit3(new[] { testBinariesPath }, new NUnit3Settings
                            {
                                Results = new[] { new NUnit3Result()
                                                  {
                                                      FileName = FilePath.FromString(projectPath.AppendPart("TestResult.Net461.xml"))
                                                  } }
                            });
                        }
                        else
                        {
                            testBinariesPath = fileWithoutExtension + ".dll";
                            _globalInfo.Cake.Information($"Testing via NUnitLite ({framework}): {testBinariesPath}");
                            _globalInfo.Cake.DotNetCoreExecute(testBinariesPath);
                        }
                    }
                    if (isVSTest)
                    {
                        testBinariesPath = fileWithoutExtension + ".dll";
                        // VS Tests
                        _globalInfo.Cake.Information($"Testing via VSTest ({framework}): {testBinariesPath}");
                        DotNetCoreTestSettings options = new DotNetCoreTestSettings()
                        {
                            Configuration = _globalInfo.BuildConfiguration,
                            Framework     = framework,
                            NoRestore     = true,
                            NoBuild       = true,
                            Logger        = "trx"
                        };
                        if (_globalInfo.Cake.Environment.GetEnvironmentVariable("DisableNodeReUse") != null)
                        {
                            options.ArgumentCustomization = args => args.Append("/nodeReuse:false");
                        }
                        _globalInfo.Cake.DotNetCoreTest(projectPath, options);
                    }

                    if (!isVSTest && !isNunitLite)
                    {
                        testBinariesPath = fileWithoutExtension + ".dll";
                        _globalInfo.Cake.Information("Testing via NUnit: {0}", testBinariesPath);
                        _globalInfo.Cake.NUnit(new[] { testBinariesPath }, new NUnitSettings()
                        {
                            Framework   = "v4.5",
                            ResultsFile = FilePath.FromString(projectPath.AppendPart("TestResult.Net461.xml"))
                        });
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void DotNetCoreDotCoverTest(this ICakeContext context, string project, DotNetCoreTestSettings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (settings == null)
            {
                settings = new DotNetCoreTestSettings();
            }

            var tester = new DotNetCoreDotCoverTestTester(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);

            tester.Test(project, settings, new DotNetCoreDotCoverTestSettings());
        }
Ejemplo n.º 3
0
 public static void DotNetCoreTest(string project, DotNetCoreTestSettings settings)
 => Context.DotNetCoreTest(project, settings);
Ejemplo n.º 4
0
 public void Test(string projectPath, DotNetCoreTestSettings settings)
 {
     AeroContext.DotNetCoreTest(projectPath, settings);
 }