Hi-hi-hi! I've written a page about our first webinar! http://semantic-mediawiki.org/wiki/1st_SMW_webinar_for_developers
Feel free to change the page, add your thoughts, interesting topics and so on. And add yourself to the list of participants! ----- Yury Katkov, WikiVote On Sun, May 12, 2013 at 2:56 PM, Yury Katkov <katkov.ju...@gmail.com> wrote: > Thanks James for your comments! Some of the links were really > interesting to read! Do you want to participate in the webinar as a > teacher? > ----- > Yury Katkov, WikiVote > > > > On Fri, May 10, 2013 at 3:01 PM, James HK <jamesin.hongkon...@gmail.com> > wrote: >> Hi, >> >>> I would like to suggest that unit/functional/integration tests would be the >>> best solution for this. I know it's not easy to get into a testing culture, >>> but various projects including parts of SMW are adopting this. It solves >>> these problems: >> >> This is certainly the right approach which also reflects the >> encouragement that new code only gets deployed if unit test(s) being >> provided to describe the intended behaviour. The reason for this is to >> shield against regressions, make change interdependencies more >> visible, and help verify edge cases. Currently SMW 1.9 deploys a set >> of 45+ phpunit test classes [j.1] together with 13+ qunit test suites >> [j.2]. >> >>> I'd suggest that beginners working with experts should be encouraged to >>> create tests as a way to understand the current code base, and that ... >> >> Yes, if someone really wants to understand how SMW works and desires >> to contribute in a meaningful way, he or she should start with unit >> tests (either extend existing ones or create additional tests for >> functions which have not yet been covered; for an analysis about the >> coverage statistics use [2]). >> >>> ... running tests suites should be a standard activity in releases. Jenkins >>> and Travis >>> (hosted) are two continuous integration platforms. >> >> Every time we submit code to the master phpunit tests are being run >> through Jenkins [j.3, j.4] and we await that qunits test are being >> handled by Jenkins as well [j.5]. >> >> == Suggestions == >> If you are working with the SMW code base: >> >> * Don't get scared just because some "fancy" jargon is being used or >> you can't find what you are looking for it at first sight >> >> * Don't try to understand the code by simply reading it, use the means >> of interacting with it. >> >> * If you are not sure what the code does write a test [0, 1] and >> extend its class/method documentation >> >> == Addendum == >> * When using PHP, facilitate the SMW namespace [a.1] and for >> JavaScript use the smw namespace to avoid polluting the global >> $/window namespace [a.2, a.3, a.4] >> >> * If you have new functionality, write your code, use dependency >> injection [a.5] (to enforce loose coupling between objects) and >> provide unit tests that will verify that those methods do what they >> suppose to do >> >> * Avoid static classes/methods [a.6] unless you are doing class >> independent object factoring, hook interaction >> >> * Split methods into units which will allow easy assertion (even if it >> means the code gets a bit longer) >> >> * JavaScript should follow similar rules by providing qunit tests and >> encapsulate modules [j.2, a.3, a.7, a.8] >> >> * Use type hinting where possible [a.9] >> >> * Use meaningful in-code comments (describe what the method does, what >> parameters being used, what is expected as return, when this method >> was first introduced) in order for docxygen (PHP) or >> jsduck(JavaScript) to generate valid documentation and help others to >> understand its indented behaviour >> >> * Avoid turning protected/private into public methods unless it is >> necessary and instead use the ReflectionClass [a.10] for testing (SMW >> has as several tests that is following this schema) >> >> * If you can't test (create) certain objects because of their >> complexity (e.g SMWQueryResult) use a mock or stub object [a.11, a.12, >> a.13] >> >> == Links == >> >> [0] http://www.semantic-mediawiki.org/wiki/Unit_tests >> >> [1] http://net.tutsplus.com/tutorials/php/hands-on-unit-testing-with-phpunit/ >> >> [2] http://phpunit.de/manual/3.2/en/code-coverage-analysis.html >> >> [j.1] >> https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/SemanticMediaWiki.git;a=tree;f=tests/phpunit >> >> [j.2] >> https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/SemanticMediaWiki.git;a=tree;f=tests/qunit >> >> [j.3] http://sourceforge.net/mailarchive/message.php?msg_id=30370087 >> >> [j.4] >> https://integration.wikimedia.org/ci/job/mwext-SemanticMediaWiki-testextensions-master/ >> >> [j.5] https://gerrit.wikimedia.org/r/#/c/53535/ >> >> [a.1] http://www.php.net/manual/en/language.namespaces.rationale.php >> >> [a.2] https://gist.github.com/hallettj/64478 >> >> [a.3] http://yuiblog.com/blog/2007/06/12/module-pattern/ >> >> [a.4] http://www.javascripttoolbox.com/bestpractices/#namespace >> >> [a.5] http://net.tutsplus.com/tutorials/php/dependency-injection-in-php/ >> >> [a.6] >> http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/ >> >> [a.7] http://qunitjs.com/cookbook/ >> >> [a.8] http://benalman.com/talks/unit-testing-qunit.html >> >> [a.9] http://php.net/manual/en/language.oop5.typehinting.php >> >> [a.10] >> http://www.mikeyd.com.au/2011/01/20/how-to-use-phps-reflectionclass-to-test-private-methods-and-properties-with-phpunit/ >> >> [a.11] http://net.tutsplus.com/tutorials/php/all-about-mocking-with-phpunit/ >> >> [a.12] >> http://codeutopia.net/blog/2009/06/26/unit-testing-4-mock-objects-and-testing-code-which-uses-the-database/ >> >> [a.13] http://phpunit.de/manual/3.7/en/test-doubles.html >> >> Cheers ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. This 200-page book is written by three acclaimed leaders in the field. The early access version is available now. Download your free book today! http://p.sf.net/sfu/neotech_d2d_may _______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel