unit-testing

Problem's running unittest test suite OO

Hello, I have a test suite to perform smoke tests. I have all my script stored in various classes but when I try and run the test suite I can't seem to get it working if it is in a class. The code is below: (a class to call the tests) from alltests import SmokeTests class CallTests(SmokeTests): def integration(self): sel...

Junit: splitting integration test and Unit tests.

Hello all, I've inherited a load of Junit test, but these tests (apart from most not working) are a mixture of actual unit test and integration tests (requiring external systems, db etc). So I'm trying to think of a way to actually separate them out, so that I can run the unit test nice and quickly and the integration tests after that....

What should I do when a co-worker rejects my commits because they contain unit tests?

Hello, I've moved from one team to another in same company. In old team (hardcore c++) we did lots of unit testing. In my new team (also c++) they do functional testing instead. During review they reject my code because of unit tests. Most of the team is interested in learning something new but not the guy who is VIP and has legacy devel...

Unit Testing in the real world

I manage a rather large application (50k+ lines of code) by myself, and it manages some rather critical business actions. To describe the program simple, I would say it's a fancy UI with the ability to display and change data from the database, and it's managing around 1,000 rental units, and about 3k tenants and all the finances. When ...

Returning a complex data type from arguments with Rhino Mocks

I'm trying to set up a stub with Rhino Mocks which returns a value based on what the parameter of the argument that is passed in. Example: //Arrange var car = new Car(); var provider= MockRepository.GenerateStub<IDataProvider>(); provider.Stub( x => x.GetWheelsWithSize(Arg<int>.Is.Anything)) .Return(new List<IWheel> { ...

Why should I bother with unit testing if I can just use integration tests?

Ok, I know I am going out on a limb making a statement like that, so my question is for everyone to convince me I am wrong. Take this scenario: I have method A, which calls method B, and they are in different layers. So I unit test B, which delivers null as a result. So I test that null is returned, and the unit test passes. Nice. The...

C++ and Dependency Injection in unit testing

Suppose I have a C++ class like so: class A { public: A() { } void SetNewB( const B& _b ) { m_B = _b; } private: B m_B; } In order to unit test something like this, I would have to break A's dependency on B. Since class A holds onto an actual object and not a pointer, I would have to ...

How do I give each test its own TestResults folder?

I have a set of unit tests, each with a bunch of methods, each of which produces output in the TestResults folder. At the moment, all the test files are jumbled up in this folder, but I'd like to bring some order to the chaos. Ideally, I'd like to have a folder for each test method. I know I can go round adding code to each test to mak...

Problem SilverLight UnitTest Exception, Help!!

My Sample Test Class: namespace Test { [TestClass] public class SampleTest { [TestMethod] public void Test() { Assert.IsTrue(true); // <---------- LOOK } } But if i do that: namespace Test { [TestClass] public class SampleTest { [TestMethod] public void Test() { Assert.IsTrue(false); //...

GH-Unit for unit testing Objective-C code, why am I getting linking errors?

Hi there, I'm trying to dive into the quite frankly terrible world of unit testing using Xcode (such a convoluted process it seems.) Basically I have this test class, attempting to test my Show.h class #import <GHUnit/GHUnit.h> #import "Show.h" @interface ShowTest : GHTestCase { } @end @implementation ShowTest - (void)testShowCreate {...

NSUserDefaults in logic test

Does NSUserDefaults work in logic tests or only in/on simulator/hardware? ...

How do I verify my EF4 Code-Only mappings?

In NHibernate, there is a method doing something like ThisOrThat.VeryfyMappings() (I don't know the exact definition of it since it was a while ago I last tried NHibernate...) I recall seeing a blog post somewhere where the author showed how to do some similar testing in Entity Framework 4, but now I cant find it. So, how do I test my E...

How can a Windows program temporarily change its time zone?

I've written a function to return the time_t value corresponding to midnight on a given day. When there is no midnight for a given day, it returns the earliest time available; that situation can occur, for example, when Egypt enters daylight-saving time. This year, the time change takes effect at midnight on the night of April 29, so the...

SQLAlchemy: who is in charge of the "session"? ( and how to unit-test with sessions )

I need some guidance on how to use session objects with SQLAlchemy, and how to organize Unit Tests of my mapped objects. What I would like to able to do is something like this: thing = BigThing() # mapped object child = thing.new_child() # create and return a related object thing.save() # will also save the child object In order to a...

How do I test ActionFilterAttributes that work with ModelState?

As suggested by (among others) Kazi Manzur Rashid in this blog post, I am using ActionFilterAttributes to transfer model state from one request to another when redirecting. However, I find myself unable to write a unit test that test the behavior of these attributes. As an example, this what I want the test for the ImportModelStateAttri...

Rails Unit Testing with MyISAM Tables

I've got an application that requires the use of MyISAM on a few tables, but the rest are the traditional InnoDB type. The application itself is not concerned with transactions where it applies to these records, but performance is a concern. The Rails testing environment assumes the engine used is transactional, though, so when the test...

unit test for proxy checking

Proxy configuration of a machine can be easily fetched using def check_proxy(): import urllib2 http_proxy = urllib2.getproxies().get('http') I need to write a test for the above written function. In order to do that I need to:- Set the system-wide proxy to an invalid URL during the test(sounds like a bad idea). Suppl...

supply inputs to python unittests

I`m relatively new to the concept of unit-testing and have very little experience in the same. I have been looking at lots of articles on how to write unit-tests; however, I still have difficulty in writing tests where conditions like the following arise:- Test user Input. Test input read from a file. Test input read from an environmen...

Testing JavaMail Related Modules

Part of my application depends on JavaMail, moving arranging messages etc. Is it possible to test this module without firing a IMAP server to run the tests on? I am always stuck when it comes to testing stuff that depends on external servers or modules. ...

TDD and encapsulation priority conflict

Hi, I just started practicing TDD in my projects. I'm developing a project now using php/zend/mysql and phpunit/dbunit for testing. I'm just a bit distracted on the idea of encapsulation and the test driven approach. My idea behind encapsulation is to hide access to several object functionalities. To make it more clear, private and prote...