unit-testing

assigning shared ptrs (boost) in constructor , unit testing

I have a C++ class(inside a dll project) whose member variables are boost::shared_ptrs to objects of other classes. Is it better to assign them inside the class constructor or have a separate init() function which does that. I am assuming the default value of pointer to T inside boost::shared_ptr is NULL. So if I do nothing inside the ...

using Moq - question

i have just started using Moq ver (3.1) and i have read blogs and what not.... anyway... i guess until you makes your hand dirty you will not learn :) okay here is what i'm testing... var newProduct = new Mock<IPartialPerson>(); newProduct.SetupGet(p => p.FirstName).Returns("FirstName"); newProduct.SetupGet(p => p.MiddleNam...

Mocking imported modules in Python

I'm trying to implement unit tests for function that uses imported external objects. For example helpers.py is: import os import pylons def some_func(arg): ... var1 = os.path.exist(...) var2 = os.path.getmtime(...) var3 = pylons.request.environ['HTTP_HOST'] ... So when I'm creating unit test for it I do some mocking (...

Java Card Unit Testing

I'd like to run my Java Card applications in some kind of emulated/simulated environment to be able to run JUnit (or any other unit test framework) tests on them. Does anyone know of such a tool? I'd prefer some open source project. ...

Is there a code-generator to create DataTable definition block from Excel Work sheet?

Hi, Basically the thing I want to achieve is to have a data-table that I want to use in my unit tests. And when I run my unit tests, I do not want to read any excel file into a data-table -or any call to Db-. So, I would like to have method that returns a data-table with the values that I can use in my test. Is there already any writ...

Unit testing in Java - what is it?

Can you explain in a few sentences: Why we need it / why they make our life easier ? How to unit-test [simple example in Java] ? When do not we need them / types of projects we can leave unit-testing out? useful links ...

Unit testing - should I split up tests or have a single test?

Hi, I hope this doesn't come across as a stupid question but its something I have been wondering about. I wish to write unit test a method which contains some logic to check that certain values are not null. public void MyMethod(string value1, string value2) { if(value1 != null) { //do something (throw exception) } ...

what is the best tool for performance regression testing

our organization is looking for a tool to help with performance testing on each release. We ship a whole bunch of new software and we want to ensure that performance on key functions has not slowed down since the last prod release. We have code in C# and Java. This can be anything from: when i run this function it takes < 2 seconds ...

NUnit: What is the most concise way to assert whether an IEnumerable contains an object of a certain type?

I have a method named RenderContent which returns object[] In my unit test, I need to assert that this array does not contain any objects of type VerifyRequest At the moment, I'm using the following Assert statement. Is there anything more concise? Assert.That( domain.RenderContent().OfType<VerifyRequest>().Count(), Is.EqualT...

junit test suites

I have a script(test.bat) that allows me to launch one java test by command line : -java -cp() org.junit.runner.JUnitCore package.Class Now I want to do the same for several java tests ? how could I do it? should I have to add the byte code for each java test? could I have an example , please? ...

How can I mock -f on an object in Perl?

I have a Perl object that has defined use overload '""' => \&name; and a name method. In my unit tests I have mocked this object, including the name method, but code like if (-d $object) still gives me Use of uninitialized value in -d .... The mocked method is not being executed. My mock code: my $CMmock = Test::MockObject::Extend...

PHPUnit Mock Objects and Static Methods

I am looking for the best way to go about testing the following static method (specifically using a Doctrine Model): class Model_User extends Doctrine_Record { public static function create($userData) { $newUser = new self(); $newUser->fromArray($userData); $newUser->save(); } } Ideally, I would use...

How to get parameters of fail case in Python unittest?

I'm running an assertEqual test case for a list of methods in a particular class. These methods are expanded from string form to something callable using getattr(). How can I get unittest to tell me the particular method which failed? Meaning: how can I get unittest to print to stdout the particular parameters which caused the failure o...

Boost Test register exception translator

Hi Does anybody know how to register my custom exception translator when using auto test cases in Boost.Test? I've found some examples (very few actually), but they do not show how to use this feature with auto test cases which are the biggest advantage of boost.test in my opinion. My example test suite: #define BOOST_TEST_MODULE S...

How to assert a private method on concrete class is called (TypeMock/NMock/etc..)?

Hello, I am trying to write a unit test for the 'IsUnique' function in the class below that looks like this: class Foo { public bool IsUnique(params...) { ValidateStuffExists(params); return CheckUniqueness(params); } private void ValidateStuffExists(params) { //does some validation } p...

unable to obtain public key for StrongNameKeyPair

I have visual studio 2008 running on a Windows 2008 virtual PC. I decided to try out the Microsoft Test Tools built into the IDE (as opposed to NUnit, which I typically use). Using the Unit Testing wizard, VS adds a new test project to the source tree, creates a bunch of unit tests. When I try and compile, I get this "Unable to obtain...

How to create a fake repository with a 1-to-many association for MVC

I'm trying to create a fake repository for unit testing with a class object that has a one to many relationship. I'm using ASP.NET MVC and Linq to SQL. My reference is Steven Sanderson's "Pro ASP.NET MVC Framework" book. I've created the Entity Classes with the association: [Table(Name = "Albums")] public class Album { [Column(Is...

Unit Testing an SOA WCF system...finding it difficult to get decent coverage.

Hello again. We are currently replacing a 20 year old C based system with a modern SOA WCF system built in .NET3.5. Our industry requires rigorous testing including good automated unit test converage. We are having issues, however unit testing our SOA system to anywhere near the extent that the C based system was unit tested. The singl...

Unit tests for interrupt-heavy code

I am writing C code for an AVR chip. The code is heavy on interrupt serivce routines which wait on serial ports, ADCs and timers. The ISRs write to buffers which the main loop examines when it gets to them. I design the buffers so that ISRs can update them while the main loop is reading them. I want to verify that this works. I have uni...

Unit testing Domain model objects

In our Core domain model design, we have got a class called "Category" whose constructor is internal by design. Since the constructor is internal, when writing unit test cases I won't be able to create the object of "Category". So my question, is it a best practice to make the constructor public just for making the "Category" class tes...