I'm just beginning to Unit Test with my projects, but I still face a problem that's throwing me off. I really want to knuckle down and get to grips with Unit Testing because I know the long term benefits are worth the effort to learn.
I work extensively with the Twitter on an almost daily basis. I create a number of applications that work with Twitter.
In a real case scenario if I want to run a Unit Test to test whether the login was successful (not using the API in this case) how would I test this is true in the Unit Test? What I would usually do in production code is test to see whether the user ID is set on the page, or whether a certain cookie exists that only a logged in user would have. Then failing that I throw an exception.
But how would I test this in a Unit Test?
Would it be the same as how I would do it in production code? For example testing to see if a known cookie exists that only a logged in user has?
There are a number of scenarios like this that I really struggle to wrap my head around when thinking in terms of Unit Testing.
I know it can get kinda tricky when building applications that rely on third parties because the third party could change the way they work and your tests are useless until you've changed them.