Friday, July 12, 2013

Continous Testing with SpecWatchr

I was impressed with Amir Rajan's talk at Austin .Net this week, and was intrigued by his use of the Continuous Testing framework SpecWatchr, so I decided to give it a spin. You can download it at here. I found the installation instructions very clear and concise. You need to download Ruby 1.9.2 and Growl.

By default it assumes nspec, but it was easy enough to change it in dotnet.watchr.rb to be NUnit.

By default SpecWatchr assumes all the tests for MyClass.cs are in a file named "describe_MyClass.cs", which mine were not. Mine tests are in MyClassTest.cs. But since this is open source, I cracked open "watcher_dot_net.rb" and changed half a dozen lines of Ruby and got it to recognize my convention. It worked like a charm.

Amir encouged the .Net group to reduce the friction in development. One of these frictions is to manually save and run tests. With SpecWatchr all you have to do is save a file and it will automagically compile and run affected tests. When all is happy you get this in the corner of your screen for a few seconds.  :
If you have a compile time error you get this:
Things to like about SpecWatchr:
  • It's free!
  • It works.
  • It's well documented.
  • It's easy to install.
Things not to like: You have to annotate your tests with a category, which is the name of the class affected.   I don't see anyway around this without some serious introspection of the code.

Overall SpecWatchr is  a great tool.

Thursday, July 11, 2013

Pictures from Austin .Net Users Group July 8, 2013: Getting things done with dynamic ASP.NET

Amir Rajan (@amirrajan) gave an interesting talk on how to use C# 4.0's dynamic objects in MVC using the Oak framework to the 50 members present. Here's a few pics just in case you were wondering what a geekfest looks like.

My jumbled notes:
  • Hey, Amir is using Emacs - my people!
  • Recommends AngularJS and Knockout
  • Rake used to build and populate system
  • used conEmu for console
  • Oak has a DynamicDB and DymanicRepository
  • "ghost methods" are not present at compile time, but added dynamically
  • Use "System.Diagnostics.Debugger.Launch();" in code to bring up the debugger
  • Amir recommended http://www.infoq.com/presentations/Simple-Made-Easy
  • The Gemini extends the properties of System.Dynamic.DynamicObject to be more Rubyesque.
  • Amir used specWatchr for automatic compiling and testing
  • For GUI testing use "canopy F#", which is a layer above Selenium.
  • Three things: reduce friction, dynamic typing, increase feedback
  • dynamic is a thing. SignalR uses it.

Tuesday, July 02, 2013

How to disable Viewstate in .Net

Viewstate reminds me of a monster in a horror movie that just won't stay dead - it keeps coming back, and back.  No matter how many silver bullets you pump into its chest, it keeps coming.
You can turn off viewstate by adding the attribute "EnableViewState" to your page.

 <%@ Page language="c#" EnableViewState="false" Inherits="MyAwesomeApp.table" %>

But it didn't work in my page.  The value of EnableViewState is overridden by the MasterPage's value.
You can also change "EnableViewState" in web.configs with

<pages enableViewState=“false” />

But depending on which subdirectory the web.config is in, it may be overridden by something else.
The way I finally killed viewstate was by explicitly setting  the "EnableViewState" variable on the page:


private void Page_Load(object sender, EventArgs e)
  {
        this.EnableViewState = false;
        ...
   }

Then it stayed dead. 
Hmmm.... hey wait ... is that a heartbeat I'm hearing?