#Doctests
Elixir developers have had doctests for years. Lukas Backström from the OTP team is on Track 1 with 'Exploring Doctests in Erlang'. Erlang catching up, or doing it differently?

#CodeBEAM #Erlang
October 22, 2026 at 12:59 PM
Up next on stage from the Erlang Solutions team is Lukas Backström and his talk "Exploring Doctests in Erlang". 🎤
October 22, 2026 at 12:53 PM
At 14:50, Lukas Backström will be Exploring Doctests in Erlang ➡️ codebeameurope.com/talks/explor...
October 22, 2026 at 8:40 AM
Eliminating warnings from ruining doctests
``` """
>>> import warnings
>>> with warnings.catch_warnings(record=False):
... warnings.simplefilter("ignore")
... run_my_func("...")
Expected output
```
September 25, 2026 at 4:06 AM
Lukas Backström, Erlang/OTP team, will speak about exploring doctests and what they could mean for Erlang at Code BEAM Europe 2026!

Documentation that can't lie about your code? Sign us up.

📅 21-22 Oct | Haarlem, NL | In-person & Virtual 

https://codebeameurope.com/<a href="/hashtag/register" class="hover:underline text-blue-600 dark:text-sky-400 no-card-link">#register
September 22, 2026 at 8:03 AM
I did have a lot of trouble getting it to create good harness usage examples as doctests that yielded tutorial docs for the demo ui. It confused reporting success in the hypothetical task tested report with reporting success to me. Several go rounds. Claude coped better.
September 8, 2026 at 1:02 AM
Add to that, sweeping API changes for better ergonomics that easily touch over a hundred files - Rust's doctests are a godsend here, I would have gone insane already without them
September 23, 2025 at 1:51 AM
I vibecoded and have been vibeusing this TypeScript doctest library: https://github.com/ianb/agent-doctest

I think it's working well? Sometimes it's very hard to tell!
GitHub - ianb/agent-doctest: An implementation of doctests for TypeScript and Markdown
An implementation of doctests for TypeScript and Markdown - ianb/agent-doctest
github.com
March 9, 2026 at 11:42 PM
E mais: pra quem gosta de escrever, doctests são ótimos pra "test-driven development".

Dá pra escrever uma especificação inteira sem usar uma linha de código sequer, e depois ir adicionando os testes para cada trecho, e então ir escrevendo o código vai dar vida a tudo.
January 23, 2025 at 4:08 PM
Até agora nunca precisei usar nada além de doctests e unittest, mas ouço falarem muito bem do pytest.

A única coisa que não gosto no unittest é o "camelCase" no nome dos métodos.
January 23, 2025 at 4:05 PM
Inclusive, seus doctests em markdown vão renderizar bonitinho no GitHub, naturalmente.

Exemplo real: github.com/IndiePython/...
github.com
January 23, 2025 at 3:58 PM
Se for do tipo q gosta de escrever e/ou quer uma documentação + didática e multimídia, pode usar doctests tbm.

Mt gente não sabe, mas doctests podem usar qualquer formato de texto, o que significa q vc pode usar, por exemplo, markdown.

Aliás, doctests podem ser achados e executados com unittest.
January 23, 2025 at 3:55 PM
I looooove doctests in Python. Since you can feed it any kind of plain text format, it can use markdown as well.

For instance: github.com/IndiePython/...
github.com
November 22, 2024 at 1:35 PM
@bitprophet what I'm saying is that you're NOT cutting out "some >5% chunk of userbase". That is not the trade-off you're making. 😅

And it's not just about using new features—it's also about wasteful CI runs, unnecessary deps, tooling conflicts, & most […]

[Original post on mastodon.social]
May 11, 2025 at 10:12 AM
Basically Notion but integrated with your comments and tests
or
Basically Rustdoc+doctests but integrated with your planning documents
August 26, 2025 at 6:52 PM
You can approximate with doctests?
July 6, 2025 at 6:52 AM
Our very own Lukas is speaking at Code BEAM Europe 2026. 🎤

Lukas has been on the Erlang/OTP team at Ericsson since 2010, working in the Erlang VM. He'll be exploring doctests in Erlang: what they are, how to use them, and why writing tests in your documentation means you get both at once.
July 2, 2026 at 8:01 PM
Some people hear “ #Haskell 's type system eliminates entire classes of bugs” and think “Cool, no tests needed”.
But what you should hear is “Cool, we can focus on more interesting tests”.

Golden tests, property tests, doctests…

wiki.haskell.org/index.php?ti...
How to write a Haskell program - HaskellWiki
wiki.haskell.org
June 16, 2025 at 10:45 AM
Now you only have to write your documentation once. The same file powers your GitHub page, your cargo doc output, and your page on crates.io, including examples and doctests.

Write it once. Ship it everywhere.
March 13, 2026 at 10:03 AM
Announcing initial 1.0 release of my include-file crate with #rustlang macros that effectively let you hide setup code in plain markdown files (md, adoc, etc.) like you can in doctests. We use these in some #AzureSDK docs to keep samples focused while still making sure they compile and work.
crates.io: Rust Package Registry
crates.io serves as a central registry for sharing crates, which are packages or libraries written in Rust that you can use to enhance your projects
crates.io
April 2, 2026 at 9:58 PM
I should also point out that doctests are compiled as standalone executables so a create_your_client function would have to be define in the doctest too. Using the include_markdown macro we could still do that in the snippet but I was hoping it was obvious given the instantiation example at the top.
November 12, 2025 at 2:38 AM
All that "setup" code we can hide in #rustlang doctests - markdown that comprises doc comments: doc.rust-lang.org/rustdoc/writ.... We can't do the same for plain markdown: those "#" prefixes will render in markdown and negatively impact readability.
November 12, 2025 at 2:19 AM
In Rust doctests, that create_your_client() still has to be defined if we want to at least compile the code snippets*. That's what the include_markdown!() macro solves. And to show async awaits, you need an async fn definition. To use the ? operator, you need a fn that returns a Result or Option.
November 12, 2025 at 2:19 AM
I always alias the module in the test running the doctests. Then the doctests don't need the module namespace.
March 19, 2025 at 3:17 PM