Archive for July 8, 2021

Thursday, July 8, 2021

Generic Test Classes in Xcode 12.5

Jon Reid:

Once or twice in my career, I’ve written an abstract test suite as a superclass, where the subclasses provide some sort of factory method. Then all the test cases in that suite get repeated for the specific instances.

I do this all the time. It’s useful when I’m making a new, optimized version of a class and want to make sure it passes all the same tests as the original. And sometimes I need multiple implementations because certain APIs are broken on certain versions of the operating system.

Maybe you’ve wanted to repeat the same tests for a different object. For example, you may want to run the same test cases over different types that implement a protocol. Maybe you tried defining a generic XCTestCase, hoping to reuse the test suite across a few types. If you tried this before, you know that it didn’t work. XCTest uses introspection and follows specific rules to gather test cases and test suites. It didn’t pick up anything generic.

But Xcode 12.5 adds support for generic test suites. Here’s how it works. Write a generic subclass of XCTestCase.

[…]

And unlike the days when I did this with a quasi-abstract base class, XCTest will not run any tests for the top-level generic suite.

This is great. Also, note that in simpler cases his example with a factory method:

class AbstractSuite<T>: XCTestCase { … }
class OneClassTests: AbstractSuite<OneClass> {
    override func makeSpecificObject() -> OneClass? {
        /* Make instance of OneClass*/
    }
}

is more than you need. I often want to test a family of classes that all follow the same interface I. Then you can just do:

class AbstractSuite<T: I>: XCTestCase { … }
class OneClassTests: AbstractSuite<OneClass> {}

and have the base class call T() directly. The subclasses don’t need any code.

Previously:

Panic’s 2016 App Store Feedback

Internal Tech Emails:

Panic’s @cabel shares App Store thoughts with Phil Schiller

Some of these sentences seem very familiar, so I wonder if this e-mail has been published before, though I can’t seem to find the link. In any event, what a good communicator Cabel Sasser is. His first point about App Store–induced stress reminds me of what Rich Siegel has spoken about, and that situation hasn’t changed. Most of the other points are also still valid today, although Apple did add a limited way to reply to customer reviews, and subscriptions make it possible—albeit curiously difficult—to implement trials without having to keep purchasing “‘fuel’ to keep the Transmit truck rolling.”

Previously:

Microsoft’s April 1998 Meeting With Steve Jobs

Internal Tech Emails has an interesting letter from Microsoft’s Ben Waldman that discusses negotiations over ClarisWorks (Apple agreed not to advertise their own product and instead preload a video promoting Microsoft Office), QuickTime, and Internet Explorer (bundling and promoting it in exchange for Microsoft having it ready when Mac OS X shipped).

The meeting took place the month before WWDC, where Apple would announce that Rhapsody was becoming Mac OS X and that Carbon would be added. Waldman writes:

Of course, this won’t be positioned as Rhapsody cancellation -- they’ll say that you’ll still have OpenStep/Yellow Box, and be able to run it on Windows, and on MacOS, except that will be one year later, and that Apple will do the “right thing” and preserve peoples’ investment in MacOS, while still providing an advanced UI runtime for people who want it (and it will still be accessible from Java). While Rhapsody required developers to do a lot of work to get pre-emption and protection, in this scenario, Apple does “95% of the work.” Later, however, in a smaller group, I asked Steve point blank if he’d ever believed in Rhapsody, and he said “no,” adding something about his duty being to NeXT shareholders.

The way I’ve heard the story told before, Carbon wasn’t part of the plan until Scott Forstall argued for it after key developers rebelled at the idea of rewriting in Cocoa. But perhaps something like that was always at the back of Jobs’ mind. It’s not clear to me when work on it started.

At the time, Apple apparently hoped to get Mac OS X running on PowerPC 604 Macs with 32 MB of RAM, but it officially shipped requiring at least a G3 and 128 MB of RAM.

Previously:

Update (2021-07-15): See also: Hacker News.

WWDC 2014 Video With Larry David

Sam Henri-Gold:

today’s vibe: scrapped WWDC 2014 intro film feat. Larry David, JB Smoove, and Evan Spiegel

See also: YouTube.

John Gruber:

One joke that might have played as funny in 2014 but wouldn’t in 2021 is the central conceit of the video — that Apple’s head of app review is a capricious jerk who makes approval decisions based on inscrutable whims.

I don’t think that would ever have gone over well.

Previously: