Unit tests using generics fail to build on Linux

Hi all,

I'm trying to build on Linux some unit tests that successfully build on Mac, and have discovered that generics do not seem to be properly supported as of Swift 5.6 (despite working on Mac since Xcode 12.5).

Is this a known issue?

More details, and a simple test case, provided here: Unit tests using generics fail to build on Linux.

(I originally posted this in the "Using Swift" category a couple of weeks ago, but it's garnered no response, so I thought this might be a better place to ask.)

cheers,

-ben

2 Likes

Yup, this is a known limitation. There is no Objective-C runtime on Linux, and the list of all test cases is instead stored in a static array. However, static stored properties are not permitted inside generic types.

I haven’t tried playing with the generated file to see if there’s some way to manually provide a computed property instead. But the general gist is that generic XCTestCase subclasses aren’t supported on Linux for the reason you’ve discovered.