<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Testing on Giedrius Statkevičius</title><link>https://giedrius.blog/categories/testing/</link><description>Recent content in Testing on Giedrius Statkevičius</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Wed, 28 Feb 2024 10:17:44 +0000</lastBuildDate><atom:link href="https://giedrius.blog/categories/testing/feed.xml" rel="self" type="application/rss+xml"/><item><title>Perils of /metrics data assertions</title><link>https://giedrius.blog/2024/02/28/perils-of-metrics-data-assertions/</link><pubDate>Wed, 28 Feb 2024 10:17:44 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=1155</guid><description>&lt;p&gt;In the Thanos project the e2e tests are written in part using assertions on the metrics data. I have encountered a few challenges with those assertions that I wanted to share with you.&lt;/p&gt;
&lt;h2 id="always-check-for-the-maximum-possible-value"&gt;Always check for the maximum possible value&lt;/h2&gt;
&lt;p&gt;Writing tests on /metrics data means your testing harness continuously checks /metrics data to see whether some metric equals some value. If the metric takes some time to reach the maximum value, you might erroneously write an equals check that checks for a smaller value. Later on, this will lead to a flaky test situation.&lt;/p&gt;</description></item><item><title>Reproducing flaky Go tests using Linux cgroups and systemd</title><link>https://giedrius.blog/2023/07/17/reproducing-flaky-go-tests-using-systemd/</link><pubDate>Mon, 17 Jul 2023 20:07:40 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=1139</guid><description>&lt;p&gt;Sometimes, the &lt;code&gt;-race&lt;/code&gt; option might not be enough to trigger/debug races in Go tests. You might have &lt;code&gt;time.Sleep()&lt;/code&gt; in a test thinking that some event will surely trigger in some time. You might run it on GitHub actions on a shared runner. Alas, you don&amp;rsquo;t see that event happen. What could have caused this? Most of the time it is because of the minimal CPU time allocated for your tests. The runners are shared between many projects and thus sometimes CPU might be very split between many processes.&lt;/p&gt;</description></item><item><title>Property-based testing in Golang</title><link>https://giedrius.blog/2019/07/08/property-based-testing-in-golang/</link><pubDate>Mon, 08 Jul 2019 19:35:23 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=529</guid><description>&lt;figure&gt;
&lt;img loading="lazy" src="https://cdn.pixabay.com/photo/2017/06/19/04/06/house-2418106%5F960%5F720.jpg"
alt="A simple house a.k.a. property"/&gt; &lt;figcaption&gt;
&lt;p&gt;A simple house a.k.a. property&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Testing software is ubiquitous and people naturally expect it to be a part of any kind of software development process. There are many different kinds of forms it can take:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;at the most rudimentary level: ad-hoc testing;&lt;/li&gt;
&lt;li&gt;integration testing;&lt;/li&gt;
&lt;li&gt;synthetic testing;&lt;/li&gt;
&lt;li&gt;and many others&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;One of the forms that are quite novel is property-based testing. Essentially, the idea is to check if the software that you&amp;rsquo;ve produced espouses certain characteristics under inputs which have certain distinctive qualities. It sounds very similar to ordinary unit tests however here the catch is that a random number generator is leveraged in this case. Or, you can think of fuzzing but for ordinary code, not binary interfaces. It lets you run a bunch of tests very quickly and find the edge cases under which your code might not work as expected.&lt;/p&gt;</description></item></channel></rss>