Stockholm syndrome

"Premature optimization is the root of all evil"

Donald Knuth

When testing makes no sense

Miro Svrtan

@msvrtan

When should we write tests?

High cost to fix?

Cost of fixing > cost of testing

When it brings "value"

Value = benefit - cost

Value = benefit - cost

Fallacy #1:

It makes my project more expensive

Do you charge for manual testing?

Bugs cost too

Ask for forgiveness, not permission

Fallacy #2:

It takes a lot of time

learning != using

Fallacy #3:

It takes extra time

Manual testing takes time as well

Fallacy #4:

ship PoC to production

Feature lifecycle

Phase 1: Exploration

Phase 2: Modelling/architecture

Phase 3: Development

Phase 4: Production

Fallacy #5:

100% code coverage


class User
{
...
    fn isAdmin() : bool{
        return value;
    }
...
}

Fallacy #6:

we have "tests"

Fallacy #7:

writing tests later is OK


class Customer
{
...
    fn shouldChargeVat(){
        if company {
            return false
        }
        return true
    }
...
}

Fallacy #8:

TDD has something to do with testing

Fallacy #9:

TDD all the way

Easier onboarding

Easier to add new features


class Customer
{
...
    fn shouldChargeVat(){
        if company {
            return false
        }
        return true
    }
...
}
class Customer
{
...
    fn shouldChargeVat(){
        if company {
            if 'DE' == country{
                return true
            }else{
                return false
            }
        }
        return true
    }
...
}

Easier refactoring

class Customer
{
...
    fn shouldChargeVat(){
        if company {
            if 'DE' == country{
                return true
            }else{
                return false
            }
        }
        return true
    }
...
}
class Customer
{
...
    fn shouldChargeVat(){

        if 'DE' == country{
            return true
        }

        if company {
            return false    
        }

        return true
    }
...
}
class Customer
{
...
    fn shouldChargeVat(){

        if 'DE' == country{
            return true
        }

        if company {
            return false    
        }

        return true
    }
...
}
class Customer
{
...
    fn shouldChargeVat(){
        if company {
            if 'DE' == country{
                return true
            }else{
                return false
            }
        }
        return true
    }
...
}

Easier rewriting

Cleaner code

It's hard to test

shitty code

Small app

One off app

Exploration phase

Job security

Thank you!

Miro Svrtan

@msvrtan

miro (at) mirosvrtan.me

Questions?

@msvrtan

When testing makes no sense (WeAreDevs 2019)

By Miro Svrtan

When testing makes no sense (WeAreDevs 2019)

WeAreDevelopers 2019, Berlin

  • 1,814