This can resolve the crash problem.
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace Core
{
public class genericLibrary
{
public void KillProcess(string processName)
{
System.Diagnostics.Process myproc = new System.Diagnostics.Process();
try
{
foreach (Process thisproc in Process.GetProcessesByName(processName))
{
thisproc.Kill();
}
}
catch (Exception Exc)
{
throw new Exception("", Exc);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
public class SuccessTests : genericLibrary
{
//[TestFixtureSetUp]
[SetUp]
public void Init()
{
KillProcess("chromedriver");
KillProcess("chrome");
}
//[TestFixtureTearDown]
[TearDown]
public void Cleanup()
{
}
}
}
Before dev this feature, the script that I'm maintain only can execute no more than 40 cases and then crash but now it can execute more than 200 cases with no crash.
You can execute these cases in the night or on VM.
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace Core
{
public class genericLibrary
{
public void KillProcess(string processName)
{
System.Diagnostics.Process myproc = new System.Diagnostics.Process();
try
{
foreach (Process thisproc in Process.GetProcessesByName(processName))
{
thisproc.Kill();
}
}
catch (Exception Exc)
{
throw new Exception("", Exc);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
public class SuccessTests : genericLibrary
{
//[TestFixtureSetUp]
[SetUp]
public void Init()
{
KillProcess("chromedriver");
KillProcess("chrome");
}
//[TestFixtureTearDown]
[TearDown]
public void Cleanup()
{
}
}
}
通过引入新功能,维护的脚本从仅能执行40个测试用例并崩溃,升级到能够无崩溃地执行超过200个测试用例。此改进包括在夜间或虚拟机上执行大量测试案例的实现。

被折叠的 条评论
为什么被折叠?



