Hey Mastodon, question for my #sysadmin and #DevOps types. Has anyone used #Pester and #PSScriptAnalyzer to set up unit testing for test driven development, particularly on (relatively) simple scripts like you might use for application detection, installation, and uninstallation from a system like #SCCM #Intune or #ManageEngine ?
Apologies for the buzzword bingo, but I’m trying to reach folks who may be following the hashtags, but not necessarily have a connection otherwise.
In a way it’s similar to the people who generate #unittests for the code they’ve just written.
Nothing against those who have this big chunk of untested legacy code and happily see that #AI gives them a good starting ground of test cases.
But like with commit messages, unit tests can answer that WHY question about your production code. Why do we need that strange if branch? Oooh because of that edge case occurring in a given use case, tested by this test case over there. That’s something you can’t derive from your production code.
In #TDD, your test cases give your production code a reason to exist. In that sense, you’d be much better off to have AI generate the production code for your tests.
One thing for my job I’m looking forward to about #AI: Refactoring large systems
Doing a refactoring that involves hundreds of classes and multiple changes of infrastructure has been a thing that can take weeks, even months.
However, if you have good test coverage, you can let an LLM can do the drudge work for you and just verify it did what it said it did.
TTD is a must anyway, if you use LLM’s for helping you werite code.
#programming #refactoring #unittests
A friend of mine is looking for one/two freelancers for the following
- Writing #unittests in #python
Basic #pqsql dB optimization.
Ideally from #Europe. If you are one or know one, please DM me.
UwU, I've just found out about `SystemState` in #Bevy
https://docs.rs/bevy/latest/bevy/ecs/system/struct.SystemState.html
It basically allows you to circumvent (mutable) borrowing issues with `App` and `World` when you have exclusive `World` access.
As it turns out, this is especially useful in #UnitTests.
See next two toots for an example...
1/3
Ah, turns out I was totally stupid!
I've forgotten to include the following Plugin:
TextPlugin
When testing in a separate crate with 0.14, I had included it, but not in my new 0.15 project. Stupid me!
Now layouts are correctly calculated in tests.
I apologize to everyone for the confusion and especially to the #Bevy project for blaming them of something that was totally my oversight.
Wondering why your (unit) test fails?
You might have changed the test data, but have you also considered changing the appropriate flags of your class under test when copying an existing test over!?
(don't ask why I'm telling you this)
Just used #ChatGPT to generate some #unittests for my C# #library. Such a big help!
Introducing MSTest SDK – Improved Configuration & Flexibility.
#dotnet #mstest #testing #unittests #csharp
https://devblogs.microsoft.com/dotnet/introducing-mstest-sdk/
So I just got a development release up for my WP-Tests-Strapon Composer package up on Github. (Not on Packagist yet as it's still under initial development.)
It is a replacement for the install-wp-tests.sh shell script that comes with some scaffolded WordPress plugins and should be easier to use and keep working.
It also does not depend on outdated things such as Subversion/SVN and uses PHP for most of its actions.
And this is why #UnitTests and #TDD are awesome/necessary (even in #Rust/ #RustLang):
The original requirement:
figure out how many columns the _result_ of diffing two CSVs in #CsvDiff have.
Do you see the error-pattern?
It's
- when we have no diff
&&
- at least one CSV has headers
which makes sense, because I've implemented the feature in the diffing logic, but at that point header information is already lost (in some other thread).
Isn't that beautiful!?
The more I dive into (unit) testing in #Python, the more I feel this is much more a form of art than it is a science.
Would anyone know of #OpenSource Python projects with good test suites that I could read to try to get better at this?
Thanks in advance!
Sometimes in a unit test I parameterize a value for a specific key in a dict. For a string I might have None, an empty string, and a test string.
What if I wanted to test the *absence* of the key? Suppose the test is non-trivial and I don't want to create a separate test.
Well one technique is to create a sentinel object:
```
class Omit: pass
_OMIT = Omit()
```
In the test I add a conditional:
```
if value != _OMIT:
testdict["key"] = value
```
Get ready to boost your #testing workflow!
ReSharper 2023.2 in #VisualStudio brings the highly anticipated feature to create #UnitTests from your production code.
It also lets you navigate between production code and their related tests!
Learn more in this post by @matkoch #dotnet
https://blog.jetbrains.com/dotnet/2023/08/01/accelerating-your-testing-workflow-with-unit-test-creation-and-navigation/
I am coming to conclusion that package scope implementations of exported package functionality are best implemented using the builder pattern to implement mocking w/o messiness
Any tool you're using to generate #documentation from #python #unittests? Ideally with the ability to run those tests as well?