Skip to content

Commit

Permalink
Move to a chapters subfolder
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Apr 6, 2015
1 parent a7f36be commit 80a02fa
Show file tree
Hide file tree
Showing 61 changed files with 160 additions and 73 deletions.
72 changes: 55 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,61 @@ An ebook about pragmatic testing strategies. Click below to get the latest epub.

| Topics | Last Updated |
| -------|--------------|
|[Core Data_migrations](core_data_migrations.md)|04 Apr|
|[Dependency Injection](dependency_injection.md)|04 Apr|
|[Developer Operations](developer_operations.md)|29 Mar|
|[Getting Setup](getting_setup.md)|04 Apr|
|[How Can_i_be_pragmatic](how_can_i_be_pragmatic.md)|04 Apr|
|[How I_got_started](how_i_got_started.md)|04 Apr|
|[Introducing Tests_into_an_existing_app](introducing_tests_into_an_existing_app.md)|04 Apr|
|[Recommended Websites](recommended_websites.md)|17 Mar|
|[Stubbed Core_data](stubbed_core_data.md)|04 Apr|
|[Techniques For_avoiding_async_testing](Techniques_for_avoiding_Async_Testing.md)|04 Apr|
|[Testing Delegates](testing_delegates.md)|29 Mar|
|[Three Types_of_unit_tests](Three_Types_of_Unit_Tests.md)|04 Apr|
|[Tooling For_different_types_of_testing](Tooling_for_different_types_of_testing.md)|04 Apr|
|[Types Of_testing](types_of_testing.md)|17 Mar|
|[Useful Terminology](useful_terminology.md)|04 Apr|
|[What And_why](what_and_why.md)|11 Sep|
|[What Is_xctest](what_is_xctest.md)|11 Sep|
|[Animations](animations.md)|05 Apr|
|[Assert On Accessing Main Context](assert_on_accessing_main_context.md)|05 Apr|
|[Behavior Testing](behavior_testing.md)|05 Apr|
|[Books](books.md)|05 Apr|
|[Core Data](core_data.md)|05 Apr|
|[Core Data Migrations](core_data_migrations.md)|05 Apr|
|[Creation Of App-Centric It Blocks](creation_of_app-centric_it_blocks.md)|05 Apr|
|[Dependency Injection](dependency_injection.md)|05 Apr|
|[Developer Operations Aka Automation](developer_operations_aka_automation.md)|05 Apr|
|[Di](di.md)|05 Apr|
|[Dispatch Asyncs Ar Dispatch Etc](dispatch_asyncs__ar_dispatch_etc.md)|05 Apr|
|[Expanding On Specta And Expecta](expanding_on_specta_and_expecta.md)|05 Apr|
|[Fakes Plus Protocols ](fakes__plus_protocols_.md)|05 Apr|
|[Fixtures And Factories](fixtures_and_factories.md)|05 Apr|
|[Getting Setup](getting_setup.md)|05 Apr|
|[How Can I Be Pragmatic With My Testing](how_can_i_be_pragmatic_with_my_testing.md)|05 Apr|
|[How I Got Started](how_i_got_started.md)|05 Apr|
|[Improving Xcode](improving_xcode.md)|05 Apr|
|[Integration Testing](integration_testing.md)|05 Apr|
|[Introducing Tests Into An Existing Application](introducing_tests_into_an_existing_application.md)|05 Apr|
|[Ipad And Iphone](ipad_and_iphone.md)|05 Apr|
|[Making Libraries To Get Annoying Tests Out Of Your App](making_libraries_to_get_annoying_tests_out_of_your_app.md)|05 Apr|
|[Mocking And Stubbing Ocmock And Ocmockito ](mocking_and_stubbing__ocmock_and_ocmockito_.md)|05 Apr|
|[Moya And Eidolon](moya_and_eidolon.md)|05 Apr|
|[Nested Before And After Usage](nested_before_and_after_usage.md)|05 Apr|
|[Network Stubbing Ohttp And Vcrurlconnection](network_stubbing__ohttp_and_vcrurlconnection.md)|05 Apr|
|[Networking In View Controllers Network Models](networking_in_view_controllers__network_models.md)|05 Apr|
|[Oss Testing In iOS](oss_testing_in_ios.md)|05 Apr|
|[Recommended Websites](recommended_websites.md)|05 Apr|
|[Restkit Plus Afnetworking](restkit_plus_afnetworking.md)|05 Apr|
|[Scroll Views](scroll_views.md)|05 Apr|
|[Starting A New Application And Using Tests](starting_a_new_application_and_using_tests.md)|05 Apr|
|[Stubbed Core Data Contexts](stubbed_core_data_contexts.md)|05 Apr|
|[Stubs And Mocks](stubs_and_mocks.md)|05 Apr|
|[Swift](swift.md)|05 Apr|
|[Techniques For Getting Around Async Testing](techniques_for_getting_around_async_testing.md)|05 Apr|
|[Techniques For Keeping Testing Code Sane](techniques_for_keeping_testing_code_sane.md)|05 Apr|
|[Techniques For Testing Different Aspects Of The App](techniques_for_testing_different_aspects_of_the_app.md)|05 Apr|
|[Test Driven Development](test_driven_development.md)|05 Apr|
|[Testing Migrations](testing_migrations.md)|05 Apr|
|[Testing Terminology](testing_terminology.md)|05 Apr|
|[Three Types Of Unit Tests](Three_Types_of_Unit_Tests.md)|05 Apr|
|[Tooling For Different Types Of Testing](Tooling_for_different_types_of_testing.md)|05 Apr|
|[Tooling For The Types Of Testing](tooling_for_the_types_of_testing.md)|05 Apr|
|[Twitter Follows](twitter_follows.md)|05 Apr|
|[Types Of Testing](types_of_testing.md)|05 Apr|
|[Unit Testing](unit_testing.md)|05 Apr|
|[Unit Testing Specta And Kiwi ](unit_testing__specta_and_kiwi_.md)|05 Apr|
|[Useful Terminology](useful_terminology.md)|05 Apr|
|[User Interactions](user_interactions.md)|05 Apr|
|[Using Xcode Pragmatically](using_xcode_pragmatically.md)|05 Apr|
|[Views Snapshots](views__snapshots.md)|05 Apr|
|[What And Why Of The Book](what_and_why_of_the_book.md)|05 Apr|
|[What Is Xctest How Does It Work](what_is_xctest_how_does_it_work.md)|05 Apr|
|[Will And Xctest 6](will_and_xctest_6.md)|05 Apr|

##### Generating the ebook

Expand Down
File renamed without changes.
File renamed without changes.
Empty file added chapters/animations.md
Empty file.
Empty file.
Empty file added chapters/behavior_testing.md
Empty file.
Empty file added chapters/books.md
Empty file.
Empty file added chapters/core_data.md
Empty file.
43 changes: 28 additions & 15 deletions core_data_migrations.md → chapters/core_data_migrations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Testing Core Data Migrations

The first time I released a patch release for the first Artsy App it crashed instantly, on every install. It turned out I didn't understand [Core Data Model Versioning](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html). Now a few years on I grok the migration patterns better but I've still lived with the memories of that dark, dark day. Since then I've had an informal rule of testing migrations with all the old build of Folio using a tool I created called [chairs](http://artsy.github.io/blog/2013/03/29/musical-chairs/) the day before submitting to the app store.
The first time I released a patch release for the first Artsy App it crashed instantly, on every install. It turned out I didn't understand [Core Data Model Versioning](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html). Now a few years on I grok the migration patterns better but I've still lived with the memories of that dark dark day. Since then I've had an informal rule of testing migrations with all the old build of Folio using a tool I created called [chairs](http://artsy.github.io/blog/2013/03/29/musical-chairs/) the day before submitting to the app store.

Chairs is a tool to back up your application's documents and settings. This meant I would have backups from different builds and could have a simulator with data from past versions without having to compile and older build.

Expand All @@ -22,27 +21,41 @@ SpecBegin(ARAppDataMigrations)
__block NSManagedObjectContext *context;

it(@"migrates from 1.3", ^{
expect(^{
context = ARContextWithVersionString(@"1.3");
}).toNot.raise(nil);
expect(context).to.beTruthy();
expect([Artwork countInContext:context error:nil]).to.beGreaterThan(0);
expect(^{
context = ARContextWithVersionString(@"1.3");
}).toNot.raise(nil);
expect(context).to.beTruthy();
expect([Artwork countInContext:context error:nil]).to.beGreaterThan(0);
});

...
it(@"migrates from 1.3.5", ^{
expect(^{
context = ARContextWithVersionString(@"1.3.5");
}).toNot.raise(nil);
expect(context).to.beTruthy();
expect([Artwork countInContext:context error:nil]).to.beGreaterThan(0);
});

it(@"migrates from 1.4", ^{
expect(^{
context = ARContextWithVersionString(@"1.4");
}).toNot.raise(nil);
expect(context).to.beTruthy();
expect([Artwork countInContext:context error:nil]).to.beGreaterThan(0);
});

it(@"migrates from 1.6", ^{
expect(^{
context = ARContextWithVersionString(@"1.4");
}).toNot.raise(nil);
expect(context).to.beTruthy();
expect([Artwork countInContext:context error:nil]).to.beGreaterThan(0);
expect(^{
context = ARContextWithVersionString(@"1.4");
}).toNot.raise(nil);
expect(context).to.beTruthy();
expect([Artwork countInContext:context error:nil]).to.beGreaterThan(0);
});

SpecEnd

NSManagedObjectContext *ARContextWithVersionString(NSString *string) {

// Allow it to migrate
NSDictionary *options = @{
NSMigratePersistentStoresAutomaticallyOption: @YES,
Expand Down Expand Up @@ -77,4 +90,4 @@ Nothing too surprising, but I think it's important to note that these tests are
These are tests that presume you still have people using older builds, every now and again when I'm looking at Analytics I check to see if any of these test can be removed.
Finally, if you don't use Core Data you may still need to be aware of changes around model migrations when storing using `NSKeyedArchiver`. It is a lot harder to have generic future-proofed test cases like the ones described here however.
Finally, if you don't use Core Data you may still need to be aware of changes around model migrations when storing using `NSKeyedArchiver`. It is a lot harder to have generic future-proofed test cases like the ones described here however.
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Xcode bots is still a bit of a mystery, though it looks like with it's second re

Travis is awesome, but they’re pretty slow with releases. Buildkite lets you run your own travis-like CI system on your own hardware. This means easily running tests for Xcode betas. It differs from Jenkins in it’s simplicty. It requires significanly less setup, and looks like it may require less maintainace overall.

#### Build

## Internal Deployment

I don’t trust Apple’s Testflight service, it seems to be that there’s a problem with it everyday.
Expand Down
Empty file added chapters/di.md
Empty file.
File renamed without changes.
Empty file.
Empty file.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
Empty file added chapters/improving_xcode.md
Empty file.
Empty file added chapters/integration_testing.md
Empty file.
File renamed without changes.
Empty file added chapters/ipad_and_iphone.md
Empty file.
Empty file.
Empty file.
Empty file added chapters/moya_and_eidolon.md
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added chapters/oss_testing_in_ios.md
Empty file.
File renamed without changes.
Empty file.
Empty file added chapters/scroll_views.md
Empty file.
Empty file.
File renamed without changes.
Empty file added chapters/stubs_and_mocks.md
Empty file.
Empty file added chapters/swift.md
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added chapters/testing_migrations.md
Empty file.
Empty file added chapters/testing_terminology.md
Empty file.
Empty file.
Empty file added chapters/twitter_follows.md
Empty file.
File renamed without changes.
Empty file added chapters/unit_testing.md
Empty file.
Empty file.
File renamed without changes.
Empty file added chapters/user_interactions.md
Empty file.
Empty file.
Empty file added chapters/views__snapshots.md
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ XCTest provides a series of macros [based on OCUnit's](https://github.com/jy/Sen

##### What is the difference between hosted test targets and unhosted

The terminology has changed recently, a hosted test used to be known as Application Tests, and unhosted was known as Logic Tests. The older terminolgy gives a better hint at how the tests would be ran. A hosted test is ran inside your application after it `application:didFinishLaunchingWithOptions:` has finished.
The terminology has changed recently, a hosted test used to be known as Application Tests, and unhosted was known as Logic Tests. The older terminology gives a better hint at how the tests would be ran. A hosted test is ran inside your application after it `application:didFinishLaunchingWithOptions:` has finished.

Unhosted tests are useful if you're testing something very ephemeral and relying only on Foundation, but anything related to UIKit subclasses will eventually require you to host the test bundle in an application.

Expand Down
Empty file added chapters/will_and_xctest_6.md
Empty file.
91 changes: 71 additions & 20 deletions generators/generate_epub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,93 @@ def create
end

markdown_files = %w[
what_and_why.md
what_is_xctest.md
how_can_i_be_pragmatic.md
how_i_got_started.md
useful_terminology.md
types_of_testing.md
Three_Types_of_Unit_Tests.md
getting_setup.md
Tooling_for_different_types_of_testing.md
developer_operations.md
introducing_tests_into_an_existing_app.md
dependency_injection.md
testing_delegates.md
Techniques_for_avoiding_Async_Testing.md
core_data_migrations.md
stubbed_core_data.md
recommended_websites.md
chapters/what_and_why_of_the_book.md

chapters/what_is_xctest_how_does_it_work.md
chapters/how_can_i_be_pragmatic_with_my_testing.md

chapters/types_of_testing.md
chapters/unit_testing.md
chapters/behavior_testing.md
chapters/integration_testing.md
chapters/useful_terminology.md
chapters/testing_terminology.md

chapters/di.md
chapters/dependency_injection.md
chapters/stubs_and_mocks.md
chapters/fakes__plus_protocols_.md

chapters/tooling_for_the_types_of_testing.md
chapters/unit_testing__specta_and_kiwi_.md
chapters/Three_Types_of_Unit_Tests.md
chapters/mocking_and_stubbing__ocmock_and_ocmockito_.md
chapters/network_stubbing__ohttp_and_vcrurlconnection.md

chapters/getting_setup.md
chapters/how_i_got_started.md

chapters/starting_a_new_application_and_using_tests.md
chapters/introducing_tests_into_an_existing_application.md

chapters/developer_operations_aka_automation.md
chapters/techniques_for_keeping_testing_code_sane.md

chapters/nested_before_and_after_usage.md
chapters/creation_of_app-centric_it_blocks.md
chapters/fixtures_and_factories.md

chapters/networking_in_view_controllers__network_models.md
chapters/animations.md

chapters/techniques_for_getting_around_async_testing.md
chapters/dispatch_asyncs__ar_dispatch_etc.md
chapters/will_and_xctest_6.md

chapters/techniques_for_testing_different_aspects_of_the_app.md
chapters/views__snapshots.md
chapters/scroll_views.md
chapters/user_interactions.md
chapters/ipad_and_iphone.md

chapters/core_data.md
chapters/assert_on_accessing_main_context.md
chapters/stubbed_core_data_contexts.md
chapters/core_data_migrations.md

chapters/making_libraries_to_get_annoying_tests_out_of_your_app.md
chapters/using_xcode_pragmatically.md
chapters/improving_xcode.md

chapters/expanding_on_specta_and_expecta.md
chapters/test_driven_development.md

chapters/swift.md
chapters/books.md
chapters/twitter_follows.md
chapters/recommended_websites.md
chapters/oss_testing_in_ios.md
chapters/restkit_plus_afnetworking.md
chapters/moya_and_eidolon.md
]

all_markdown = get_markdown_files
diff = (markdown_files|all_markdown) - (markdown_files & all_markdown)
if diff.length > 0
puts "Looks like #{diff.join(" ")} is/are missing."
puts "Looks like #{diff.join(", ")} is/are missing."
end

`pandoc -f markdown -t epub --epub-cover-image=assets/Cover.png -o pragmatic_testing.epub --smart --toc --epub-stylesheet=assets/pragmatic_style.css #{ markdown_files.join(" " )}`
end

def get_markdown_files
mdfiles = []
Dir.foreach('.') do |item|
Dir.foreach('./chapters') do |item|
next if item == '.' or item == '..'
next if item[-2..-1] != "md"
next if item == "README.md"

mdfiles << item
mdfiles << "chapters/" + item
end
mdfiles
end
Expand Down
6 changes: 3 additions & 3 deletions generators/generate_toc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create

def add_markdown_files_to template
mdfiles = []
Dir.foreach('.') do |item|
Dir.foreach('./chapters') do |item|
next if item == '.' or item == '..'
next if item[-2..-1] != "md"
next if item == "README.md"
Expand All @@ -31,8 +31,8 @@ def add_markdown_files_to template
end

mdfiles.each do |mdfile|
title = mdfile[0..-4].sub("_", " ").gsub(/\w+/) { |word| word.capitalize }.gsub("Ios", "iOS")
last_updated = File.ctime(mdfile).strftime("%d %b")
title = mdfile[0..-4].gsub("_", " ").gsub(/\w+/) { |word| word.capitalize }.gsub("Ios", "iOS")
last_updated = File.ctime("./chapters/" + mdfile).strftime("%d %b")

template += "|[#{title}](#{mdfile})|#{last_updated}|\n"
end
Expand Down
13 changes: 0 additions & 13 deletions how_can_I_be_pragmatic.md

This file was deleted.

Binary file modified pragmatic_testing.epub
Binary file not shown.
4 changes: 0 additions & 4 deletions testing_delegates.md

This file was deleted.

0 comments on commit 80a02fa

Please sign in to comment.