views:

87

answers:

1

Hi there,

I'm writing some unit tests in cocoa for a data driven application.

I've got a constants header file which defines a whole heap of variables including paths to the databases etc.

I was wondering if it's possible to get all the classes to use a different set of constants which would link to a testing version of the database etc.

I've tried redefining the constants, but it doesn't take effect globally.

+3  A: 

You could instead have a structure that contained all of the constants used and pass it into your objects' constructors. Normally that structure will be whatever values are necessary to run but when you're testing, you would instead pass a structure with the fields initialized to test parameters

I'm know absolutely nothing about objective C though, so I'm not sure if this is possible for you.

SnOrfus