testing(5/0)
Test a dotnet web service
Here are the basic steps to configure a service that uses HttpClient to make HTTP calls which can be unit tested. ⚠️ This was developed for a dotnet 7 console app. You may find that your code is more/less verbose. The Service Under Test First, here’s a basic template for a dependency-injected service. You can use these examples to refactor an existing service to inject an IHttpClientFactory so we have an interface to mock in our tests.…
Choose your analogy carefully
The analogies one uses to describe their work disclose important aspects about how they view one’s craft. These analogies then shape the tools which are created and dangle on one’s toolbelt. Two of my favorite analogies, teaching and pottery share the same goal of undermining the development-as-bricklaying mindset around which many development tools have organized. The brick-laying analogy (and the managerial mindset that software is “built”) has created tools which don’t fit the work.…
Test web components with playwright
So you’ve created a native web component or two. How do you test them in popular browsers? Packages There are a few tools to install. First, test-runner to find and execute our tests. It comes with the Mocha test framework by default, and we won’t change it. Might as well install chai too for test assertions and expectations. Second, the browser runner Playwright plugin. Playwright integrates headless browser testing into the mix, allowing us to run our code inside a browser context for every one of the major browser binaries (chromium, firefox, webkit).…
Teach the computer with tests
Thanks to Mikel Evins' post Programming as teaching I realized that my favored programming style is at odds with common practice. I knew something was off from the kinds of conflict I’d have with other developers, but Mikel made the difference stand out to me. Early in my corporate programming career I became enamoured with testing. Unit tests, integration tests, component tests, you name it. It was strange to me at that time that I hadn’t cared much about testing until I joined a corporation.…
Connect peer containers with SSH keys
For the complete, working example, check out the code: connected-containers. Introduction Have you ever had that sinking feeling when you remember that you’ve solved this problem before but you don’t remember where you stashed the solution? And the sense of frustration searching for it, especially when it doesn’t turn up in your usual places? Yea, that’s why I’m writing this down where I can find it. I love the concept of sandboxed environments that can be provisioned and destroyed at whim, which is why I love Docker.…