Skip to main content

Representative Line: Unique Testing

22 hours 2 minutes ago

Nikolai M's team had a flaky CI/CD build. About 0.5% of the time, one of their tests would fail: frequent enough to be annoying, but not so frequent that it motivated management to assign anybody to investigate. Nikolai eventually dug in, taking the initiative.

Microsoft's implementation of UUIDs calls them GUIDs. The GUID is, per the docs, really just a wrapper around UUID algorithms, and supports a variety of different UUID variants. I'm sure at some historical point, this wasnt't true, and Microsoft had some weird internal algorithm. That's not really here nor there, but the test that was failing was failing because of an assertion relating to GUIDs.

Assert.DoesNotContain("000", transactionId.ToString());

transactionId is a GUID. This line converts it to a string and checks if it contains "000". They're attempting to check if it's an empty UUID, and they've assumed that three sequential zeroes in the output would be an impossible event. This is untrue. Nikolai measured it, and found it happens 0.5527% of the time- 1-in-181.

So this is a bad test, and could be made better with a more thorough check. Or it could leverage the built in constant GUID.Empty, which is a UUID where every bit is zero.

And it's that which really bugs me, honestly. Even if you didn't know about the constant, the idea of constructing an empty GUID seems like the obvious choice. Though I suppose you'd have to check the docs to find out how to construct a GUID directly, and if you're already reading the docs, the chances of you seeing the built-in constant are probably higher than 0.5527%.

[Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.
Remy Porter

Bananas That Don't Go Brown To Hit Supermarkets Thanks to DNA Editing

1 day 1 hour ago
An anonymous reader quotes a report from The Guardian: It is the bane of every fruit bowl: sliced banana that turns brown before it has reached the table. But such woes could soon be a thing of the past, with gene-edited bananas that keep their freshly peeled color now one step closer to reaching British shoppers. According to Tropic, the Norwich-based agricultural-biotechnology company that developed the fruit, the bananas have the same taste and texture but stay "fresh, yellow and appetizing long after peeling and slicing." Gilad Gershon, the chief executive of Tropic, said the flesh of the new banana resisted browning for an extra day or two -- and longer if chilled. He added that the innovation could make it easier to add bananas to prepackaged products such as fruit salads and breakfast pots, as well as reducing waste. [...] Tropic developed the bananas by using a gene-editing technology called Crispr-Cas9 to alter all three copies of a single gene within the fruit. As a result, they were able to reduce the production of polyphenol oxidase, an enzyme that causes browning. A similar approach has been effective in reducing browning in other produce, including mushrooms. Tropic said the non-browning bananas could reduce food waste and CO2-equivalent emissions along the supply chain by more than 25%. "This could support an annual reduction in CO2 emissions of over 9m tonnes in the banana export market alone," the company said. [...] Gershon said Tropic had gained regulatory approval for the non-browning bananas in 10 other countries including Japan, Brazil and the Philippines. The fruit is already being grown in Latin America.

Read more of this story at Slashdot.

BeauHD