So I've come around to CodeFiles. Unlike CodeBehind, they don't require a compile, don't interrupt the application pool and don't require Sitecore to reload. Which means you're testing logic changes fast. I've paired them with custom exceptions to mark logical goals, like
... throw new Exception("Logged-in logic reached."); ...
Which gets me to that good TDD place of setting a goal, and writing just enough code to meet the goal, and getting feedback fast. Of course, the downside is that you aren't building up a library of tests, as you would with true TDD. Another downside of this approach is that you build up a lot of logic in your ascx.cs file, which you need to refactor out before you head home for the day. But I found the combination of Extract Method followed by Refactor/Move gets code where it should live pretty handily. And testing logic changes in 1 second feedback cycles is just dreamy.
No comments:
Post a Comment