veganism.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Veganism Social is a welcoming space on the internet for vegans to connect and engage with the broader decentralized social media community.

Administered by:

Server stats:

293
active users

#unittesting

1 post1 participant0 posts today

Boas práticas de programação fazem bem para as pesquisas quantitativas... e, por acaso, para a prática clínica:

blog.leonardof.med.br/2025/ckd

Fui usar "teste de unidade" ("unit testing", em inglês) no código de análise estatística que eu estava escrevendo, e descobri que uma calculadora online da Sociedade Brasileira de Nefrologia estava errada.

Formulário HTML com o título 'Calculadora de eGFR', subtítulo 'Equação CKD-EPI 2021', e os campos 'Idade (anos)', 'Sexo' e 'Creatinina Sérica (mg/dL)'. Abaixo do subtítulo há dois parágrafos explicando a calculadora, e no rodapé do formulário está escrita a equação com seus valores especiais.
Pesquisa, atenção primária e maisA calculadora CKD-Epi 2021 da SBN está funcionando – Pesquisa, atenção primária e mais
Replied to John-Mark Gurney

@encthenet @rachelplusplus Dunno if you've considered this, or would consider it, but pytest has a plugin, pytest-fakefs (github.com/pytest-dev/pyfakefs), that implements an in-memory filesystem complete with file objects that you can use to test file handling code without having to put things on disk. IMO the plugin ecosystem for handling things like this is one of pytest's biggest advantages over unittest.

Or if you prefer, pytest also has built-in functionality that makes working with temporary files pretty easy.

GitHubGitHub - pytest-dev/pyfakefs: Provides a fake file system that mocks the Python file system modules.Provides a fake file system that mocks the Python file system modules. - pytest-dev/pyfakefs

A couple weeks ago, I gave a talk at @omt_conf on What's New in Testing. That talk was recorded, but while I wait for it to be edited and published, I published an edited (and updated!) version of my speaker notes from that talk.

There's a lot new in testing since last year. I'm still surprised there wasn't a WWDC video about all the new things you can do.

rachelbrindle.com/2025/06/26/w

rachelbrindle.comWhat's new in Testing, 2025 EditionSoftware Engineer. Maker. Pilot.

I made a small tool called SpecSCAD to help write unit tests for #OpenSCAD functions using a #BDD-style syntax (describe, it, expect), inspired by Mocha/Jest. #UnitTesting

It runs @OpenSCAD in headless mode via Bash and outputs simple pass/fail results. No external dependencies beyond OpenSCAD + Bash.

It’s very lightweight, but can help to catch issues early in function-heavy code. Maybe it’s useful to others too — feedback welcome!

For a long time, when I first started writing tests, I felt so unproductive writing tests. I would try to write the test as fast as possible so I could move on to the "real" code.

Then one day when a production deployment failed due to missing a simple test I realized the critical value of tests... darrenmcleod.com/2025/06/test-

www.darrenmcleod.comTest Code
More from Darren J. McLeod
Property-based testing in Haskell with QuickCheck falsify

A few days ago, Edsko de Vries of Well-Typed published an in-depth article on property-based software testing, with a focus on the concept of “shrinking.”

In brief, property-based testing is sort-of like fuzz testing but for algorithms and protocols. Like fuzz testing, random test cases are procedurally generated, but unlike fuzz testing, the test cases are carefully designed to verify whether a software implementation of an algorithm satisfies a specific property of that algorithm, such as:

  • “this function always fails if the index is larger than the array”
  • “this function always returns a result in n*log(n) number of iterations for input dataset of size n
  • “the sequence of log messages is guaranteed to obey this rules of this particular finite-state automata: (connect | fail) -> (send X | fail) -> (receive Y | receive Z | fail) -> success .”

Shrinking is the process of simplifying a failed test case. If you have found some input that makes your function return a value when it should have thrown an exception, or produce a result that does not satisfy some predicate, then that input is a “counterexample” to your assertion about the properties of that function. And you may want to be able to “shrink” that counterexample input to see if you can cause the function to behave incorrectly again but with a simpler input. The “QuickCheck“ library provides a variety of useful tools to let you define property tests with shrinking.

Defining unit tests with such incredible rigor takes quite a lot of time and effort, so you would probably do not want to use property-based testing for your ordinary, every-day software engineering. If you are, for example, being scrutinized by the US Department of Government of Efficiency, you would likely be fired if you were to take so much time to write such high-quality software with such a strong guarantee of correctness.

But if you are, for example, designing a communication protocol that will be used in critical infrastructure for the next 10 or 20 years and you want to make sure the reference implementation of your protocol is without contradictions, or if you are implementing an algorithm where the mathematical properties of the algorithm fall within some proven parameters (e.g. computational complexity), property-based testing can give you a much higher degree of confidence in the correctness of your algorithm or protocol specification.

www.well-typed.comfalsify: Hypothesis-inspired shrinking for Haskell