生成多个测试用例报告无法与Nuit控制台一起使用 [英] Generate multiple test case report is not working with Nuit console
问题描述
如果 我运行多个测试 视觉案例 工作室 它是 生成多个
$
log 报告每种测试方法 但是 如果我全部运行 测试案例使用Nunit控制台(2.6.4),它&bbsp
只为第一种方法生成一个测试用例报告,并且不会为其他测试方法生成任何报告。
嗨suraj111,
我在侧面测试过,我使用了这个示例代码,并运行nunit.exe打开test.dll文件,我得到了一个测试结果文件(.xml),如下所示,并且包含三个测试用例:
我运行nunit.exe:
然后打开(文件 - >打开项目)我的dll文件然后运行:
我测试过的代码是 这些:
使用System;使用NUnit.Framework
;
namespace Bank
{
公共类账户
{
私人小数余额;
private decimal minimumBalance = 10m;
public void存款(十进制金额)
{
余额+ =金额;
}
public void提取(小数)
{
余额 - =金额;
}
public void TransferFunds(账户目的地,小数)
{
if(balance - amount< minimumBalance)
抛出新的InsufficientFundsException() ;
destination.Deposit(amount);
提款(金额);
}
公共小数余额
{
get {return balance; }
}
公共十进制MinimumBalance
{
get {return minimumBalance; }
}
}
公共类InsufficientFundsException:ApplicationException
{
}
[TestFixture]
public class AccountTest
{
帐户来源;
帐户目的地;
[SetUp]
public void Init()
{
source = new Account();
source.Deposit(200m);
destination = new Account();
destination.Deposit(150m);
}
[测试]
public void TransferFunds()
{
source.TransferFunds(destination,100m);
Assert.AreEqual(250m,destination.Balance);
Assert.AreEqual(100m,source.Balance);
}
[测试]
[ExpectedException(typeof(InsufficientFundsException))]
public void TransferWithInsufficientFunds()
{
source.TransferFunds (目的地,300米);
}
[测试]
[忽略("决定如何实施交易管理")]
public void TransferWithInsufficientFundsAtomicity()
{
try
{
source.TransferFunds(destination,300m);
}
catch(预期InsufficientFundsException)
{
}
Assert.AreEqual(200m,source.Balance);
Assert.AreEqual(150m,destination.Balance);
}
}
}
如果有可能你可以分享 您的代码示例,让我们进行研究。
祝你好运,
陈伟伟
If i run multiple test case in visual studio it is generate multiple
log report for each test method But if i run all test case using Nunit console(2.6.4) , it
generate only one test case report for first method and it is not generate any report for other test method.
Hi suraj111,
I’ve tested in side, I used this sample code, and run the nunit.exe to open test.dll file and I got one test result file(.xml) shown below, and there are three test case included:
I run the nunit.exe:
And open(File -> Open project) the my dll file in it then run:
The code what I tested is these:
using System; using NUnit.Framework; namespace Bank { public class Account { private decimal balance; private decimal minimumBalance = 10m; public void Deposit(decimal amount) { balance += amount; } public void Withdraw(decimal amount) { balance -= amount; } public void TransferFunds(Account destination, decimal amount) { if (balance - amount < minimumBalance) throw new InsufficientFundsException(); destination.Deposit(amount); Withdraw(amount); } public decimal Balance { get { return balance; } } public decimal MinimumBalance { get { return minimumBalance; } } } public class InsufficientFundsException : ApplicationException { } [TestFixture] public class AccountTest { Account source; Account destination; [SetUp] public void Init() { source = new Account(); source.Deposit(200m); destination = new Account(); destination.Deposit(150m); } [Test] public void TransferFunds() { source.TransferFunds(destination, 100m); Assert.AreEqual(250m, destination.Balance); Assert.AreEqual(100m, source.Balance); } [Test] [ExpectedException(typeof(InsufficientFundsException))] public void TransferWithInsufficientFunds() { source.TransferFunds(destination, 300m); } [Test] [Ignore("Decide how to implement transaction management")] public void TransferWithInsufficientFundsAtomicity() { try { source.TransferFunds(destination, 300m); } catch (InsufficientFundsException expected) { } Assert.AreEqual(200m, source.Balance); Assert.AreEqual(150m, destination.Balance); } } }If it's possible you could share a sample of your code and let's have a research.
Best regards,
Fletch
这篇关于生成多个测试用例报告无法与Nuit控制台一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!