Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Unit Testing Mechanism #173

Merged
merged 10 commits into from
Nov 13, 2013
Merged

Implement Unit Testing Mechanism #173

merged 10 commits into from
Nov 13, 2013

Conversation

jleandroperez
Copy link
Contributor

  • Updated our Integration Tests to use Xcode 5 testing framework.
  • Implemented Mock-Objects mechanism.
  • Implemented Remote-Debugging Unit Test.

@@ -597,10 +597,13 @@ - (NSArray*)exportPendingChanges {
// This routine shall be used for debugging purposes!
NSMutableArray* pendings = [NSMutableArray array];
for(NSDictionary* change in changesPending.allValues) {

NSString* startVersion = [change[CH_START_VERSION] copy] ?: @"";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tricks like this in a protocol parser make me a little uncomfortable. Should CH_START_VERSION always be present in a change? What happens if it's not? Should we at least log an error, and maybe bail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as i can tell, under real circumstances that should always be present. However, while running unit tests (with Simperium 100% disconnected from the backend) i got a couple scenarios in which it's set to nil, and the unit test itself can crash (due to a nil insertion inside a NSDictionary).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked Beau's specs:

sv : the source version for the entity the change applies to. Note: not sent for new objects.

So it's okay, actually, not to send it. I'll update the code so the export call simply doesn't add that field, instead of adding a blank.


@implementation MockSimperium

+(MockSimperium*)newMockSimperium
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming convention for a class method that returns an instance should probably be mockSimperium instead of newMockSimperium.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under the 'old school' memory management guidelines, if a method returns a non-autorelease instance, the name should include 'new' keyword. With ARC, that's not the case anymore right? (haven't re checked Apple's guidelines).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find anything official here. But yeah, new feels old school. =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After verifying that under ARC, the lack of the 'new' keyword doesn't make any difference, we're officially nuking the new keyword.

Ref: 8a5e053

Thanks again!

@mikejohnstn
Copy link
Contributor

Great cleanup, cool tests. This'll come in very handy.

@jleandroperez
Copy link
Contributor Author

Thank you!. Let's add tests for everything (Gradually speaking!).

jleandroperez added a commit that referenced this pull request Nov 13, 2013
Implement Unit Testing Mechanism
@jleandroperez jleandroperez merged commit 96466a1 into develop Nov 13, 2013
@jleandroperez jleandroperez deleted the unit-tests branch November 13, 2013 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants