RSSAmplifier

Blog

mokacoding

A blog about testing, iOS development, productivity, and blabber about software in general.

mokacoding.comRSS feed ↗210 posts

Latest posts

iTerm2 microphone permission for Claude Code

How to grant microphone permission to iTerm2 on macOS to use with Claude Code voice mode

Porting save files from Delta iOS to the RG35XX Plus

How to add roms and save files to the RG35XX Plus 2nd SD card on the stock OS

Pokémon Emerald Starters Cheat Codes on Delta iOS

How to load cheat codes for the Pokémons Emerald starters on the Delta emulator app for iOS

How XcodeGen reduced the TDD in Swift codebase by 58,000+ lines

A code generation story.

Tests Are The Best Kind Of Documentation

Unit tests are a vital tool for writing quality code. They also happen to be the best kind of documentation for your software, the kind that never gets out of date.

How to convince your team to adopt TDD

Test-Driven Development is an excellent way of writing code but many people push back against it. To convince your team to adopt it, lead by example. Don't preach. Let the quality of the code your wrote with TDD talk for itself and only suggest TDD when people ask about it.

The case for creating a merge commit

My current thoughts on which merge strategy to use on GitHub. "Create a merge commit" will help you make sense of how code changed over time without removing the option for a high-level overview of the changes on the main branch.

XCTNSPredicateExpectation is slow, and what to do about it

Each XCTNSPredicateExpectation requires a timeout of at least 1.1 seconds. That's will unnecessarily slow down your test suite. You can use Nimble's toEventually instead and make your tests as fast as possible.

When to test a @Published property using sink

Swift @Published properties come with an associated Combine Publisher that emits values over time. This free XCTest tutorial explains when to write a unit test that accesses the property directly and when it's instead necessary to subscribe to it using the sink operator.

A real-world example of TDD catching bugs

I published a YouTube video with a tutorial on implementing the FizzBuzz algorithm using Test-Driven Development. While recording, I made a couple of thinking or coding mistakes, and, sure enough, the tests immediately pointed them out.

How to write unit tests for SwiftUI apps

To test SwiftUI applications, don't test SwiftUI code. The SwiftUI framework doesn't lend itself to writing unit tests so don't try to shoehorn views in your test harness. Instead, split layout declaration form content generation logic.

Test-Driven Development in Swift is now available

My book, Test-Driven Development in Swift, is now available in online bookstores everywhere. You'll learn Test-Driven Development writing a real-world SwiftUI application, including events-flow management with Combine, networking, local storage, and third-party libraries.

WWDC21: What's New in Testing

A roundup of the testing-related new features announced at WWDC 2021. Including Xcode Cloud, how to test code using async/await, the new XCTExpectFailure and addTearDownBlock APIs, and the new Test Repetition configuration in Test Plans.

How to test Swift async/await code with XCTest

Swift 5.5 and Xcode 13 introduce the async/await pattern for concurrent code. This tutorial post shows how to write unit tests for asynchronous code in Swift using the XCTest framework.

How to write better tests for Swift date comparisons

Testing Swift date comparison code with XCTest can result in indeterministic tests because of the passage of time. To make tests robust and deterministic, decouple them from the system clock by injecting the reference date.

On the benefits of distributed work

Working from home doesn't have to be lonely. Going from remote to distributed can bring massive benefits to employees satisfaction and company productivity.

How to manage complex inputs in your Swift tests with Scenario Builders

When writing unit tests in Swift for complex objects, you may need to write a lot of setup boilerplate code in the arrange phase. Scenario Builders are a pattern that extracts and encapsulated all that logic in a single component with an English-like API. This tutorial shows how to build a Scenario Builder in Swift and looks at its pros and cons.

A World Without Slack

How to establish a workflow that minimizes unscheduled, unstructured communication and maximizes focus and productivity.

A distributed asynchronous release process

My latest post on mobile.blog explores two simple conventions Automattic uses to remove the need for synchronous meetings in their app release process.

Working Backwards

How working your way backwards from your desired outcome can make you more productive, focused, and motivated.

How waiting in line can improve your focus

Embrace boredom to train your brain to sustain focus when working on demanding tasks

Unit Testing Combine Publisher Cheatsheet

Snippets to test the behavior of Combine Publishers in XCTest ready to copy and paste into Xcode

Boring Iterations. Interesting Steps.

Camille Fournier encourages us to "Make Boring Plans" and move in small iterations.

How to migrate from SwiftUI to UIKit App Delegate Life Cycle in Xcode

This free tutorial shows how to migrate an existing app with SwiftUI life cycle to use UIKit App Delegate instead

How to stick with your New Year resolutions

The start of a new year is a great time to work on self-improvement, but unless you take the right steps, your New Year resolutions might not stick.

How to set default values in Swift compiler-generated initializers

You can get the Swift compiler to generate an initializer with default values for your structs, if you're willing to put up with a bit of mutability.

How to improve your Test-Driven Development workflow by asking "Do I need this yet?"

The "You Don't Need It Yet" technique to ship software on a schedule results in fast real-world feeback. The same mindset can be applied with Test-Driven Development to move between the Red, Green, and Refactor stages faster.

Write better Swift unit tests with custom XCTest assertions

The XCTest Swift testing framework has a limited offer of assertions. There's only so much you can do with XCTAssertTrue and XCTAssertEqual. This XCTest tutorial shows how to create custom assertions to make your unit tests and UI tests shorter and clearer.

How to write unit test assertions for Swift Result values

Result is one of the most useful types in the Swift language. Learn how to write better unit tests using Result in this XCTest tutorial.

When experiments go wrong

Scientist can learn a lot from failed experiments. To do so, they must be methodical and collect all sorts of information. Softwar developers can learn a lot from failures, too. What are the practicies that can make learning easier?

How to merge pull requests with a commit that improves your Git history

When merging a pull request on GitHub, it helps to replace the default merge commit title with the PR title or an equally descriptive one. This will make your Git history more informative, and developers will understand the changes in the Git log faster.

How to bypass the SwiftUI App when running unit tests

How to make the unit tests of your SwiftUI app safer and faster by preventing them from running the program startup flow. This will avoid all of the launch operations like network requests or reads from the local storage that would affect the global state.

How to rename a file in Vim

There are many ways to rename a file in Vim. Here's three.

How to remove trailing whitespaces from all files in a folder

Here's a shell command to trim all the trailing whitespaces in all the files of the current folder.

How to make the View to ViewModel relationship clear

Using Swift's nested types helps making it clear that a view model belongs to a view.

Dependency Injection in SwiftUI

This post shows two ways of achieving dependency injection in SwiftUI: using @EnvironmentObject or a View Model Factory.

What can a pipe wrench teach us about software engineering?

With his famous pipe wrench lecture, Vannevar Bush taught young MIT engineers the value of precision. The same teaching holds true for software developers.

Hyperfocus by Chris Bailey

Hyperfocus will teach you how to concentrate effectively and let your mind wander to reach creative insights.

You Don't Need It Yet

YDNIY is a purposeful restraint of what you decide to build in the interest of delivering value to the users as soon as possible and consistently.

"That's funny…" moments are learning opportunities

The most exciting phrase to hear in science, and software development, the one that heralds new discoveries, is not "Eureka!" but "That's funny…"

Will iOS 14 Destroy Your Productivity?

iOS 14 introduces Widgets, a feature that makes it incredibly easy to get distracted.

Replace Triple-state Boolean with Enumeration

Triple-state Booleans can be ambiguous to work with. Replace them with an enum to make the code clearer.

How to decouple unit tests from values that change frequently

When the output value of a function changes often but the logic to pick it doesn't, adding a separation layer will make unit tests easier to maintain.

How to add co-authors to a Git commit

How to check if macOS app is notarized

How to reverse a file in the terminal

How to verify your SSH private key password

How to check if array contains element with block in Ruby

Honesty-Oriented Programming

If you focus on writing honest code, you'll end up with software that is easier to understand and work with.

Referential Transparency in Swift

An explanation of what referential transparency means with examples in Swift