Hi Bernhard, That sounds interesting. See you at the symfony day cologne and i hope we can talk about this topic some minutes :)
Frank Am 02.08.2009 um 13:24 schrieb Bernhard Schussek: > Hi Kris, > >> Lime 2.0 looks like a pretty big development effort. Nice work! Can >> you >> share some of your goals in rewriting lime with the group when you >> have a >> moment? I'm sure I'm not the only one curious. > > My primary goal with Lime 2 was to remove most of lime's shortcomings > and implement some badly needed features like the mock generation > support or support for setup/teardown code. I wanted to achieve this > goal without losing lime's simplicity and ease of use, because this is > what really separates lime from other libraries like PHPUnit. > > Maybe I should shortly list some of the new features: > > 1. Setup/Teardown code > > You can write your tests in two ways: Either you write them in > xUnit-style test classes, where each method starting with "test" is a > seperate test, or you write a typical lime test script with > annotations. I presented this technique in a blog post a while ago: > http://webmozarts.com/2009/06/30/easy-unit-testing/ > > 2. Mock generation support > > You can generate fake objects (mocks and stubs) very easily. A test of > an exemplary class User including stubs could look like this: > > $storage = LimeMock::create('sfSessionStorage'); > $storage->read('catalog_id')->returns('123'); > $storage->replay(); > $user = new User($storage); > $t->is($user->getAttribute('catalog_id'), '123'); > > I think the code is pretty self-explanatory. First you generate the > mock object providing some class or interface name (that doesn't > necessarily have to exist), then you record some method calls and > optionally return values or exceptions that should be thrown. In the > end, you switch the mock to replay mode, where the recorded methods > can be called and return the recorded values. > > 3. Support for exception testing > > You can easily test whether your code throws specific exceptions now: > > $t->expect('InvalidArgumentException'); > $calculator->add(2, 'Foobar'); > > 4. Better test output > > In lime comparing objects or arrays was rather tedious. If you > compared arrays or objects with many values, the whole objects/arrays > were printed if only one value did not match. This often led to > infinite loops if the printed object contained circular references, > and it was tedious to find the non-matching value manually. > > In Lime 2, only the first non-matching value is printed when comparing > objects or arrays. This helps greatly finding the error in your code. > See the attached screenshot for example. > > 5. Better comparisons > > lime had another problem with comparisons. Doubles, for instance, > cannot be compared using straight ==, because 1/3 != 1-2/3 due to > rounding errors. Thus you need specific logic for comparing doubles, > which is implemented in lime_test::is(). > > What happens if you compare two arrays that contain doubles? The > comparison fails, because lime compares arrays with ==, and once again > we have our rounding problem. Lime 2 avoids this problem by comparing > all values manually, even in composite data structures such as arrays > or objects. Internally, all values are wrapped in LimeTester objects > for the specific data type (f.i. LimeTesterDouble) which is then > responsible for any comparisons. > > The great implication of this feature is that you can override test > methods for specific data types. You could, f.i., override the is() > method for Doctrine_Record objects (and descendants) only. Or you > implement like() for any class or interface of your choice. It's up to > you. > > I'm thinking about natively providing support for comparing arrays > with like(), greaterThan() etc. > > 6. Better error management > > In lime tests, PHP notices and warnings are easily overlooked. Lime 2 > outlines notices and warnings more clearly and even shows them in the > test summary. See the attached screenshot for example. > > 7. Integration with CI tools > > Lime 2 should natively integrate with popular CI tools. My goal is to > support Sismo and phpUnderControl, but I still have to see how that > works out. > > > That's it for now, thanks for reading :-) If you have any questions, > please go ahead. > > > Bernhard > -- > Software Architect & Engineer > Blog: http://webmozarts.com > > > > <lime-tester-array-output.png><lime-test-suite-output.png> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en -~----------~----~----~----~------~----~------~--~---
