Hello all
I need to write a unit tests for a class that reads a xml file and parses it's content.
How can I Mock the file reading ? Because all the content of the tests should be against read file .
I use nmock2 with nUnit.
Thanks
...
Hi all
I have 2 questions about functionality of nunit.
What is the difference between [TestFixtureSetUp] and [SetUp] attributes ?
I am writing a some class with tests and I see that half of my test functions need one setup,
And an another half needs another set up.
How can I have in one class two little different SetUp functions tha...
We use Boost statically linked with our app but now I wan't to use Boost Test with an external test runner and that requires the tests themselves to link dynamically with Boost.Test through the use of the required BOOST_TEST_DYN_LINK define.
Is this going to be a problem or is the way Boost Test links completely unrelated to the way the...
So, I previously wasn't really in the practice of writing unit tests - now I kind of am and I need to check if I'm on the right track.
Say you have a class that deals with math computations.
class Vector3
{
public: // Yes, public.
float x,y,z ;
// ... ctors ...
} ;
Vector3 operator+( const Vector3& a, const Vector3 &b )
{
retur...
When you have a simple method, like for example sum(int x, int y), it is easy to write unit tests. You can check that method will sum correctly two sample integers, for example 2 + 3 should return 5, then you will check the same for some "extraordinary" numbers, for example negative values and zero. Each of these should be separate unit ...
IEnumerable<ReportReceipt> expected = new List<ReportReceipt>()
{
new ReportReceipt("fileName1","Hash1","some comments1")
};
IEnumerable<ReportReceipt> actual = new List<ReportReceipt>()
{
new ReportReceipt("fileName1","Hash1","some comments1")
};
Assert.IsTrue(expected.SequenceEqual(actual));
I'm running MSTest with VS 2008....
Am doing a bit of unit testing on a function which attempts to open a new file, but should fail if the file already exists. when the function runs sucessfully, the new file is created, so i want to delete it after every test run, but it doesn't seem to be working:
class MyObject_Initialisation(unittest.TestCase):
def setUp(self):
...
I am attempting to run basic unit tests.
When I run rake test:units the output initially shows files being loaded i.e. rake_test_loader, *_test.rb.
There is no output after this however. The task exits with no errors.
I have also tried running a test indivdually with > ruby unit/some_test.rb
There is no output from that either.
Any id...
Im running the nunit-console program to test some assemblies after the build script is run. The TestResult.xml is then copied to a static web server.
Im looking for a tool that could format the xml output into a nice html page that displays the results similar to how the NUnit GUI does it. Im looking for a color coded hierarchal display...
Consider the following code:
[Test]
public void WidgetTest()
{
foreach (Widget widget in widgets)
{
Assert.AreEqual(0, widget.SomeValue);
}
}
If one of the asserts fails, I will get a very unhelpful error message like the one below:
1) Test Failure : WidgetTest.TestSomeValue
Expected: 0
But was: 1
at WidgetT...
Hey all,
I'm looking to run a bunch of tests with one object with different parameters in the setUp function.
How do I do this? I tried using the @dataProvider, but that doesn't work with setUp I quickly found out..
Here's what I'd like to do (using @dataProvider):
/*
* @dataProvider provider
*/
function setUp($namespace, $args) {
...
how do i create a test suite in junit4 ??
...
I'm using Infinitest for continuous testing when I do java development and i really miss the instant feedback when I develop in .nET
How do I do continuous testing in C# & .NET?
EDIT: I'm not looking for continuous integration, like CruiseControl, TeamCity etc.
It's an instant feedback tool that works with your IDE that I'm looking fo...
How do I increase the default execution timeout for my unit tests? I have a unit test which calls a web service. It often runs for longer than 10 seconds, which produces a timeout error. I'm using Visual Studio Team System 2008.
...
I there, I have completed my project and I'm doing a university subject that involves unit testing. When I right click on my function, it only shows up an options to create a unit test when my CLR support setting is set to safe.
Problem is my project will not compile with this setting on?...it needs to be set to pure.
How can I work ar...
I have a python program that imports pythoncom (and uses pythoncom.CoCreateInstance from it). I want to create a unittest for the program logic without it importing pythoncom (so I can run the test on Linux as well).
What options are there? Can I do it without modifying the system under test?
What I found so far:
sys.modules["pythonco...
Hello people,
I am diving into the world of unit testing. And i am sort of lost. I learned today that unit testing is testing if a function works.
I wanted to test the following function:
public function getEventById($id)
{
return $this->getResource('Event')->getEventById($id);
}
So i wanted to test this function as follows:
p...
Hi,
It has been decided to write some unit tests using moq etc..It's lots of legacy code c#
(this is beyond my control so cannot answer the whys of this)
Now how do you cope with a scenario when you dont want to hit the database but you indirectly still hit the database?
This is something I put together it's not the real code but give...
I'm learning TDD, and I have a question about private / protected variables. My question is: If a function I want to test is operating on a private variable, how should I test it?
Here is the example I'm working with:
I have a class called Table that contains an instance variable called internalRepresentation that is a 2D array. I want...
Isn't it true that every assert statement can be translated to an Assert.IsTrue, since by definition, you are asserting whether something is true or false?
Why is it that test frameworks introduce options like AreEquals, IsNotNull, and especially IsFalse? I feel I spend too much time thinking about which Assert to use when I write unit...