← Back to team overview

elementary-dev-community team mailing list archive

Re: about TDD (Test Driven Development)

 

I don't see how the test suite relates to Granite but yes; it would be
helpful ( and hard ) to build something on top of GLib.Test to
ease the writing of unit tests.

But the best approach IMHO is to adapt Vala to support TDD.

Something like this:

class Demo : Object {    public void random_string (int length, string
alphabet) {

    require( alphabet.lenght > 0 ) {

        // BODY HERE

    }

    test {
       utils = Demo ();
       assert ( utils.random_string(5, "ab").length == 5 );
       s = utils.random_string(1000, "a");
       for ( c in s ) {
          assert(c == 'a');
       }
    }
}

BR,

Daniele




2013/9/3 Erasmo Marín <erasmo.marin@xxxxxxxxx>

> So, if TDD is so good and GLib.Test is so bad or incomplete, why not
> to extend it in something like Granite.Test? would be that possible?
> useful? hard?
>
> 2013/9/3 Alex Lourie <djay.il@xxxxxxxxx>:
> > I believe that this has been discussed quite thoroughly already. For now,
> > TDD as a development philosophy is not really appropriate for the eOS
> > development. That is not a direct result of tools missing for
> unittesting,
> > but again, a development process decision.
> >
> > That said, I think that testing is important for elementary, and we are
> > going to try and look for some automation testing. I will post my
> findings
> > shortly about that.
> >
> >
> > On Tue, Sep 3, 2013 at 3:38 PM, Daniele S. <oppifjellet@xxxxxxxxx>
> wrote:
> >>
> >> I do understand your point, and I agree with that. But what I want to
> >> discuss is not if the TDD is generally a good approach ( hint. it is )
> >> but if it's the right approach for a community driven project like
> >> elementaryOS.
> >>
> >> about this statement:
> >>
> >> "So if you can test something in a language (if its build in or not) you
> >> can run do TDD."
> >>
> >> You should also consider the effort ( and the cost ). When using a
> >> programming language that doesn't offer unit test facilities applying
> TDD
> >> may be tedious and require lots of effort ( like writing your own test
> suite
> >> engine ).
> >>
> >> ( as background, I'm used to agile methods, at work we use SCRUM and
> PRTI,
> >> we are introducing TDD but at a slow rate )
> >>
> >> BR,
> >>
> >> Daniele
> >>
> >>
> >> 2013/9/3 Michael Lazarski <michael@xxxxxxxxxxx>
> >>>
> >>> Hello,
> >>>
> >>> TDD isn't a Technic its a mindset or a philosophy.
> >>>
> >>> It came from the Agile manifesto http://agilemanifesto.org/ .
> >>>
> >>> So if you can test something in a language (if its build in or not) you
> >>> can run do TDD.
> >>>
> >>> Often young developers don't see the need for writing test and even
> >>> experienced hackers don't do.
> >>>
> >>> How often where you hunting a bug and you had to log stuff to hunt the
> >>> bug?
> >>>
> >>> Or how often you see code and you go WTF?
> >>>
> >>> Here come test in handy. Now the young padawan may ask why?
> >>>
> >>> IF a test is good written you don't need to log stuff because when you
> >>> break something the test will tell you what and where.
> >>>
> >>> Now the young padawan says: But should't I write good code instead?
> >>>
> >>> Yes, but the god like programmer is a Myth and if you think your a good
> >>> hacker your probably a very bad one! << Facts !
> >>>
> >>> But how test can make me faster understand someones code?
> >>>
> >>> Simple: People how have Higher Mathematics in School/College/University
> >>> probably have seen mathematical proofs.
> >>>
> >>> Most students think that Teachers do that to annoy the shit out of you
> >>> but this is just wrong and you probably very bad at Mathematics too...
> >>>
> >>> In Mathematical proofs like in test we can see the essence of what the
> >>> hacker wanted to do.
> >>>
> >>> By looking at what he tested and how we can understand how things works
> >>> and how the shouldn't.
> >>>
> >>>
> >>> SO you can not test and the code must be rewritten a lot like in
> >>> contractor. maybe not today or maybe not in 1 or 2 months but at some
> point
> >>> it will happen and if the guy how wrote the shitty code is not there
> anymore
> >>> you will prey for test and a documentation of the code.
> >>>
> >>> OH and when people say: look at the source and you will understand it.
> >>> they are pretty dumb too...
> >>>
> >>> Hacking is Art! If I look at the Mona Lisa and someone else will do we
> >>> maybe see the same thing but think very different!
> >>>
> >>> So don't be dumb! Test and Document if you have the workflow right it
> >>> will take not more then 10 minutes of a work hour but it will save
> letter
> >>> tons and tons of work hours!
> >>>
> >>>
> >>> Greetings lampe2
> >>>
> >>> Gruß Michael Lazarski
> >>>
> >>> --------------------------------------------------
> >>> life simply so other people can simply life!
> >>> Inspired by: https://vimeo.com/17576843
> >>>
> >>> -----Ursprüngliche Nachricht-----
> >>> Von: Daniele S. <oppifjellet@xxxxxxxxx>
> >>> Gesendet: Die 3 September 2013 13:40
> >>> An: elementary-dev-community@xxxxxxxxxxxxxxxxxxx
> >>> Betreff: [Elementary-dev-community] about TDD (Test Driven Development)
> >>>
> >>>
> >>> I read some threads focusing on TDD, so I wanted to create one where we
> >>> can continue that conversation without being offtopic.
> >>>
> >>> I'd say my two cent about TDD and elementary os development.
> >>> In my opinion our current environment is obstile to TDD for serveral
> >>> reason:
> >>>
> >>> 1. Vala doesn't support TDD out of the box (  other languages do:
> >>> http://cobra-language.com/ )
> >>> 2. GLib.Test is a unit test facility that is available to Vala
> >>> applications, however it's not as advanced as CppUnit, NUnit and
> equivalent
> >>> 3. TDD is great for libraries and backends, not so much for GUI
> >>> applications and Database driven applications.
> >>> 4. TDD needs lots of fakes and mocks to be written, and that could be
> >>> very time expensive ( and tedious sometimes )
> >>>
> >>> Some references to Unit testing on vala apps:
> >>> http://valadoc.org/#!api=glib-2.0/GLib.Test
> >>> http://esite.ch/2012/06/26/writing-tests-for-vala/
> >>>
> >>> feel free to comment
> >>>
> >>> BR,
> >>>
> >>> Daniele "OpenNingia" Simonetti
> >>>
> >>> --
> >>>
> >>> Mailing list: https://launchpad.net/~elementary-dev-community
> >>>
> >>> Post to     : elementary-dev-community@xxxxxxxxxxxxxxxxxxx
> >>>
> >>> Unsubscribe : https://launchpad.net/~elementary-dev-community
> >>>
> >>> More help   : https://help.launchpad.net/ListHelp
> >>>
> >>>
> >>> --
> >>> Mailing list: https://launchpad.net/~elementary-dev-community
> >>> Post to     : elementary-dev-community@xxxxxxxxxxxxxxxxxxx
> >>> Unsubscribe : https://launchpad.net/~elementary-dev-community
> >>> More help   : https://help.launchpad.net/ListHelp
> >>>
> >>
> >>
> >> --
> >> Mailing list: https://launchpad.net/~elementary-dev-community
> >> Post to     : elementary-dev-community@xxxxxxxxxxxxxxxxxxx
> >> Unsubscribe : https://launchpad.net/~elementary-dev-community
> >> More help   : https://help.launchpad.net/ListHelp
> >>
> >
> >
> >
> > --
> > Alex Lourie
> >
> > --
> > Mailing list: https://launchpad.net/~elementary-dev-community
> > Post to     : elementary-dev-community@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~elementary-dev-community
> > More help   : https://help.launchpad.net/ListHelp
> >
>

References