SwiftDocOrg / DocTest

An experimental tool for testing Swift example code in documentation.
358 stars 9 forks source link

Consider an option to codegen XCTTests #20

Open schwa opened 4 years ago

schwa commented 4 years ago

As a big fan of python doctests I actually had a proof of concept swift doctest working a few years ago. I didn’t get much beyond proof of concept (although I do have some doctest comments still sprinkled in my codebase). One difference between your doctest and mine was that my version didn’t try to run the tests - it would merely codegen XCTest files that you could include and run as part of your normal unit test phase.

I definitely see the advantage of doctest being used to run the tests - but using it for codegen-ing removes some of burden of installing another tool, integrates well with other testing tools/CI etc and allows users to migrate away from doctest if it for whatever reason it doesn’t work out for them.

Just a suggestion of course.

mattt commented 4 years ago

I agree that this would be a useful feature. I'd say the story for code generation in Swift is only "so-so" right now. Template-based systems like Sourcery have their uses, but I don't think it'd be a great fit here. I think SwiftSyntaxBuilder is really promising, and I hope that gets some more attention soon.