Friday, December 4, 2009

FlexUnit extended for long method names

Today i extended FlexUnit a bit, so we can see long methodNames. When we try to follow the BDD schema "Given A When B Then C" the names can get really long. Here is one example, and it is not even the longest one.

test_WhenTransactionsAreLoaded_ThenTransactionsAreSortedByDateDescending

However, long methodNames are truncated in the right panel of FlexUnit. So your beautiful methodName ends up looking like:

test_WhenTransactionsAreLoad...

Not very helpful. So the first thing i did, was to replace the mx:Label with a mx:Text to allow for multiple lines. But to take it a little bit further, i also reformatted the methodName. Underscores are replaced by newlines and the came case text is broken up into words. So in the end it looks like this

test
When Transactions Are Loaded
Then Transactions Are Sorted By Date Descending

Much better!
Some things don't fit well in this schema though, eg single character words like "a" or interface names like ISomething. But still, the overall result is much more readable than it was before. The screenshot below shows what it looks like in FlexUnit.



Addendum:
I have added a entry to the bug base for flex unit. Please vote for it, if you want to support it: https://bugs.adobe.com/jira/browse/FXU-83

No comments:

Post a Comment