unit-testing

How to best turn on/off unit tests using #defines

I have a file with unit tests testOne() {...} testTwo() {...} ... but when I am troubleshooting I would like to turn off all except the unit test that is causing problems (due to massive amount of logging). At the moment I have done like this: #if 0 testOne() {...} #endif .. #if 1 testTroublesome() {...} #endif But I was wo...

Boost.Test and Forking

I'm using Boost.Test for Unit testing and am currently running various mock servers in separate threads which get launched from within each test. In order to more accurately test my code the mock server's should really be in separate processes. I was thinking about doing something along these lines: MY_TEST() if (fork() == 0) { r...

Robotium: searchText

Hi all, I have a strange situation I can't explain myself. The following code works well: solo.sleep(1000); assertTrue(solo.searchText("Banking")); but the following code fails: assertTrue(solo.waitForText("Banking", 1, 1000)); Can someone can explain me this? Kind regards, Alban. ...

Using XSpec and XQuery - how to execute XQuery statement on context

Heya, We've got a series of XML documents that have validation operations performed on them via XQuery to locate whether nodes exist in the document and if they hold the right values. We would like to introduce some unit testing for all these XQuery statements, similar to the unit testing introduced for XSLTs however we've hit a slight...

Shoulda rspec matchers :on => :create

I am using some of the Shoulda rspec matchers to the test my model, one of them being: describe Issue do it { should_not allow_value("test").for(:priority) } end My problem with this is that my validation in my model looks like this: validates_format_of :priority, :with => /^(Low|Normal|High|Urgent)$/, :on => :update So when runn...

What are strict and non-strict mocks?

I have started using moq for mocking. Can someone explain me the concept of strict and non-strict mocks? How can they can be used in moq? edit: in which scenario do we use which type of mock? ...

VS2010 only runs one TestMethod

I am admittedly new to unit testing in VS2010, but I'm having a problem that I can't seem to resolve. No matter how many classes I have in Test project decorated with [TestClass] or how many methods within those test classes are decorated with [TestMethod]. Whenever I run all tests in the solution. only one test gets run. and it pass...

Unit testing interfaces and method calls

There are two testing scenarios I am unclear on. Both appear at first sight to create very brittle tests. First, when should one unit test the interface (i.e. verify that an interface has a set signature)? Second, when should one "test the sequence diagram" (a term I just made up) - meaning verifying calls are being made to the appropr...

How do I unit-test a class that depends on another class to change the state of something?

I have a class A which contains an instance of class B, and function foo of A calls function set of B, which updates the state of B. Here is a code example (in Javascript): A = function () { this.init = function (b) { this.b = b } this.foo = function (val) { this.b.set(val) } this.bar = function () ...

PyUnit with a variable number of tests

What I would like to do, is create a folder, where people can put in a file for testing, and have pyunit automatically expand in order to run the test as a separate test. Currently, what I'm doing is: class TestName(unittest.testcase): def setUp(self): for file in os.listdir(DIRECTORY): # Setup Tests def te...

using AbstractTransactionalDataSourceSpringContextTests with Hibernate & DbUnit - inserted data not found

All, I'm attempting to write a unit test for a Dao that uses Hibernate. I'm also using Spring, so I'm trying to extend AbstractTransactionalDataSourceSpringContextTests and also use DBUnit to insert data into the database before each test in the onSetUpInTransaction method. From my logs, I can see that DbUnit is able to successfull...

Mocking The PDO Object using PHPUnit

I'm having difficulty mocking the PDO object with PHPUnit. There doesn't seem to be much information on the web about my problem but from what I can gather: PDO has 'final' __wakeup and __sleep methods that prevent it from being serialised. PHPunit's mock object implementation serialises the object at some point. The unit tests then...

Writing maintainable unit tests with mock objects

This is a simplified version of a class I'm writing a unit test for class SomeClass { void methodA() { methodB(); methodC(); methodD(); } void methodB() { //does something } void methodC() { //does something } void methodD() { //does something } } Whil...

References/guides for nunit unit testing

Can anyone sugggest good references/guides for getting started with nunit and visual studio 2008. (Apart from the Nunit documentation itself!). I specifically want to set up a test project in vs 2008. ...

Unit Test for creating a sharepoint site fails

I have some code that creates a sharepoint site. When the code runs as part of the solution it works. However, when I run it as a unit test I get the following error: The test adapter 'WebHostAdapter' threw an exception while running test 'CreateSiteTest'. The web site could not be configured correctly; getting ASP.NET process informat...

read csv using jmeter(starting from x)

Hi, I'm writing a jmeter script and I have a huge csv file with a bunch of data which I use in my requests, is it possible to start not from first entry but from 5th or nth entry? ...

[Blackberry] How can I debug a .jar library source code imported in my unit testing project?

Hi, I'm working on a Blackberry application (JDE 4.6.1 + Windows machine + Elipse). Currently my workspace involves two main project Unit testing application (called unitT) my application (calle myApp) Basically,I compile the myApp project in a .jar file and I import this as a library in the uniT project (so I can reference it). The ...

What is the correct way to do this using TDD principles?

I'm new to TDD, and I'm trying to learn the right way to do things. So I have to make a javascript class for a web browser extension that stores the user's information to HTML5's localStorage (I'll call this class UserInfoStorage). However, I want to make my extension cross-browser compatible, and the way to interact with localStorage is...

Unit test a firefox extension?

I'm working on a Firefox extension and started building automated tests using jsUnit. I run into permission errors running the tests from the TestRunner as soon as my extension code refers to any XPCom components. Is there a better tool for me to use for this, or how I can get around the permissions issues and continue to use jsUnit? ...

Applying test classes to dynamic page elements with jQuery

Hi, I am working with a tester who is using Selenium in my latest project. I was trying to get some information out of him as to how i needed to name my CSS classes applied to the dynamic elements on the page that he will be testing. I think he is rather new to this himself so was going to put our findings here for comment: Testing ...