Note that there are some explanatory texts on larger screens.

plurals
  1. POCode coverage using mono and nunit tests
    primarykey
    data
    text
    <p>I'm trying to test a file (Account.cs) using testfile (AccountTest.cs). I run OSX 10.6 with Mono Framework (and nunit-console). </p> <p>Below is Account.cs</p> <pre><code> namespace bank { using System; public class InsufficientFundsException : ApplicationException { } public class Account { private float balance; public void Deposit(float amount) { balance+=amount; } public void Withdraw(float amount) { balance-=amount; } public void TransferFunds(Account destination, float amount) { destination.Deposit(amount); Withdraw(amount); } public float Balance { get { return balance;} } private float minimumBalance = 10.00F; public float MinimumBalance { get{ return minimumBalance;} } } } </code></pre> <p>And here is AccountTest.cs:</p> <pre><code> namespace bank { using NUnit.Framework; [TestFixture] public class AccountTest { [Test] public void TransferFunds() { Account source = new Account(); source.Deposit(200.00F); Account destination = new Account(); destination.Deposit(150.00F); source.TransferFunds(destination, 100.00F); Assert.AreEqual(250.00F, destination.Balance); Assert.AreEqual(100.00F, source.Balance); } [Test] [ExpectedException(typeof(InsufficientFundsException))] public void TransferWithInsufficientFunds() { Account source = new Account(); source.Deposit(200.00F); Account destination = new Account(); destination.Deposit(150.00F); source.TransferFunds(destination, 300.00F); } } } </code></pre> <hr> <p>I compile these two files by:</p> <pre><code>mcs -t:library Account.cs mcs -t:library -r:nunit.framework,Account.dll AccountTest.cs </code></pre> <p>And get Account.dll and AccountTest.dll respectively.</p> <p>To run the test I use:</p> <pre><code>nunit-console AccountTest.dll </code></pre> <p>and it runs as it should, giving me the appropriate failures and passes.</p> <p>However, now I want to use mono's code coverage ability to asses these tests. I'm reading the tutorial <a href="http://mono-project.com/Code_Coverage" rel="noreferrer">http://mono-project.com/Code_Coverage</a> to run the coverage tools. And to use it I would need to compile into *.exe file rather than *.dll file. </p> <p>If someone could help me with the main class of the AccountTest.cs file, I would be able to then compile it in exe and from there use the coverage tool.</p> <p>Thanks a tonne in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload