Good code needs good tests - a Code Monkeys redux, Friday 14th May over lunchtime

8 views
Skip to first unread message

Tim Booth

unread,
Apr 20, 2021, 5:19:59 AM4/20/21
to ashworth-c...@googlegroups.com, ashworth-bioin...@googlegroups.com
(Sorry for the double posting I wasn't sure of the best mailing list to use. Please feel free to pass this on.)

Hi All,

Many moons ago, as part of the Code Monkeys lunchtime sessions in Ashworth, I did a short presentation and interactive session on unit testing, specifically looking at testing code in Python (cos that's my main language) and making use of some examples from Martin Jones' then-recent book ("Effective Python Development for Biologists" - no bookshelf should be without it!).

After a recent chat with Bryan Wee I found my old notes and promised I'd do a  re-run of the session. For those who don't remember Code Monkeys it's nothing formal, just an hour where I'll show you some stuff and we'll discuss and write some tests together. To participate you just need some way to edit and run Python 3.6+ (a shell on Eddie for example) and this link:

https://eu.bbcollab.com/guest/e24e7666574e448eaccb5eaa320ba504

Start time is Friday 14th May @12:30

Also I'll be putting some updated bits and pieces on to GitHub:

Why should you care about unit and regression tests for your code? In short, testing will help you write better, cleaner, more maintainable code, even for small projects. Have you ever spent hours searching your code for a bug, inserting hundreds of 'print()' statements to try and root out the problem, starting to doubt your own memory and sanity as you stare at inexplicable errors and garbled output files? I've not done this in years, and learning the value of unit testing is one of the big reasons why.

As I said above, the examples I have are based on Python, but all languages have test frameworks and all programs can benefit from using them (yes, even in R! https://towardsdatascience.com/unit-testing-in-r-68ab9cc8d211) so there should be something for all you hackers. See you there.

Tim Booth

Developer and Bioinformatician
Edinburgh Genomics





The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. Is e buidheann carthannais a th’ ann an Oilthigh Dhùn Èideann, clàraichte an Alba, àireamh clàraidh SC005336.

Donald Dunbar

unread,
Apr 20, 2021, 12:22:13 PM4/20/21
to ashworth-c...@googlegroups.com
Great stuff Tim. But what do you mean *even* R? ;0)
Donald

--
The wiki is at:
https://www.wiki.ed.ac.uk/display/AshCodes/Ashworth+Codemonkeys
The mailing list archive is at:
https://groups.google.com/forum/?fromgroups#!forum/ashworth-code-monkeys
If you have trouble editing the wiki or emailing the group, let me know: sujai...@ed.ac.uk
---
You received this message because you are subscribed to the Google Groups "Ashworth Codemonkeys" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ashworth-code-mo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/ashworth-code-monkeys/966546cab6b0dd080b919ee448638a4b7e631158.camel%40ed.ac.uk.


--
Donald Dunbar
donald...@gmail.com

Donald Dunbar

unread,
May 14, 2021, 7:40:31 AM5/14/21
to Ashworth Codemonkeys
This is on now, if anyone fancies joining.....
Donald

Hi All,

Many moons ago, as part of the Code Monkeys lunchtime sessions in Ashworth, I did a short presentation and interactive session on unit testing, specifically looking at testing code in Python (cos that's my main language) and making use of some examples from Martin Jones' then-recent book ("Effective Python Development for Biologists" - no bookshelf should be without it!).

After a recent chat with Bryan Wee I found my old notes and promised I'd do a  re-run of the session. For those who don't remember Code Monkeys it's nothing formal, just an hour where I'll show you some stuff and we'll discuss and write some tests together. To participate you just need some way to edit and run Python 3.6+ (a shell on Eddie for example) and this link:

https://eu.bbcollab.com/guest/e24e7666574e448eaccb5eaa320ba504

Start time is Friday 14th May @12:30

Also I'll be putting some updated bits and pieces on to GitHub:

Why should you care about unit and regression tests for your code? In short, testing will help you write better, cleaner, more maintainable code, even for small projects. Have you ever spent hours searching your code for a bug, inserting hundreds of 'print()' statements to try and root out the problem, starting to doubt your own memory and sanity as you stare at inexplicable errors and garbled output files? I've not done this in years, and learning the value of unit testing is one of the big reasons why.

As I said above, the examples I have are based on Python, but all languages have test frameworks and all programs can benefit from using them (yes, even in R! https://towardsdatascience.com/unit-testing-in-r-68ab9cc8d211) so there should be something for all you hackers. See you there.

Tim Booth

Developer and Bioinformatician
Edinburgh Genomics

Reply all
Reply to author
Forward
0 new messages