Homepage | About Me | Testing ASP.net Book | Best Blog Posts | Personal Projects | Follow me on Twitter | GitHub | SlideShare | RSS
Blog.BenHall.me.uk

Not much of an invitation - Thanks Google

Saturday, February 06, 2010

This week Google was kind enough to invite me to "Google Apps Premier Edition". This is the email:

2010-02-06_1621.png

I would love to use the premier edition as the free version is amazing! Sadly, the invitation was only for the 30 day free trail. After gaining my interest, Google then went and lost my interest while also making me disappointed. Not the ideal way to make your users feel.

When sending over promotional emails, take into account how the user will feel and their thought process when reading your email.

DDD8: Albacore and Testing ASP.net Web Applications using Ruby

Monday, February 01, 2010

Yesterday was the excellent DDD8. Thank you to all who attended. I gave a grok talk and a full presentation. The grok talk was on Albacore,  while the full presentation on Testing ASP.net Web Applications using Ruby. The slides are below. If you have any questions\feedback then do please let me know.

Don’t forget, if you are interested in learning more about Testing ASP.net then my book has recently been released.

cover[1]

Download demo from http://github.com/BenHall/Kona/zipball/DDD8

Labels: , ,

Quick screencast: Installing Git

Wednesday, January 20, 2010

I have spoken to a number of people who have been put-off by installing Git as it seems difficult. To prove that it’s not, I decided to put together a very quick screencast to highlight the main points. As I wanted it to be quick and to the point I decided not to add voice-over and instead use call-outs where required.

If you want to know more, then I really recommend you check out TekPub as they have done a great series on how to take full advantage of Git.

Labels:

Time for a new stubbing and mocking syntax?

Monday, January 18, 2010

When using IronRuby to test C# applications we are still faced with similar issues as with C# – the different is how we can handle them. For example, to stub the HttpRequestBase in C#, we could use Rhino Mocks as follows.

var stubbedHttpRequest = MockRepository.GenerateStub<HttpRequestBase>().Stub(x=>x.ApplicationPath).Return(“~/test”);

I do really like this syntax and think it works for C#.  However, if we are looking to use Ruby and a dynamic language we have the potential to be more inventive.

IronRuby has an excellent framework called Caricature which allows you to fake CLR objects. For example, here we are stubbing the HttpRequestBase from MVC.

require 'caricature'
include Caricature
stubHttpRequest = isolate System::Web::HttpRequestBase     
stubHttpRequest.when_receiving(:application_path).return("~/test")    
stubHttpRequest 

However, this got me thinking. With Ruby being dynamic, how could we take advantage when defining fakes? For example, what about the following syntax:

stubHttpRequest = stub 'System::Web::HttpRequestBase
                          .ApplicationPath.returns("~/test") &&
                          .FilePath.returns("")'

This would stub two properties, ApplicationPath and FilePath to return “~/test” and an empty string respectively. If we wanted to handle method calls and arguments, we could have the following:

stubHttpRequest = stub 'System::Web::HttpRequestBase
                          .SomeMethodCall("WithArgument").returns(SomeObject.new) && 
                          .SomeOtherMethod(*).returns(-1)'

Here we stub two methods, one stubs with a particular argument (must be the string “WithArgument”) while the other matches on any argument.

My aim is to reduce the ceremony associated with the act of stubbing and instead focus on the true intent of the defined behaviour.

Note: Imagine the ‘refactoring’ problem has been solved, and changing the method names would also update the tests.

If we look at other languages, for example Javascript’s jqMock and Ruby’s NotAMock are using a similar syntax to C#.

var alertMock = new jqMock.Mock(window, "alert");
alertMock.modify().args("hello world new!").returnValue();

I think it is time to start looking beyond the existing syntax and reveal our true intent. What do you think?

Labels: ,

Testing ASP.net using Ruby – CodeMash session

Sunday, January 17, 2010

This week I went over to CodeMash, an amazing community and cross-language conference in the US. I had some amazing conversations, meet some amazing people and gave a session on Testing ASP.net using Ruby.

I would like to say thank you to everyone who attended and the organisers for giving me the opportunity to speak. If you have any questions\comments, then please give me a shout, Twitter is the best way.

The code I used during the demo can be found on GitHub - http://github.com/BenHall/Kona 

I created a tag so you can download the zip of the code, now and in the future without being affected by other changes - http://github.com/BenHall/Kona/zipball/CodeMash_2010. In future I plan to keep working on this code as a sample so you might want to keep an eye on the repository. 

Also, if you would like to know more about Testing ASP.net web applications, then I recommend you take a look at the book I co-authored, check out http://www.testingaspnet.com

Labels: , , ,

RSpec, IronRuby and RubyMine

Saturday, January 09, 2010

RSpec, IronRuby and RubyMine is an amazing combination. Here is a screenshot of an example I’m currently working on…

Rubymine_tests_passing

All I do is execute the Rake command below, which exists in my rakefile.rb. Rubymine does the rest! Very cool.

desc "Run all examples"
Spec::Rake::SpecTask.new('examples') do |t|
  t.spec_files = FileList['examples/**/*.rb']
end

Adding IronRuby and JRuby to your OSX path

Saturday, December 26, 2009

After downloading IronRuby and JRuby to do some hacking over the Christmas period, I wanted to add them to my PATH variable on OSX. In Windows, this is fairly easy to find but is hidden a few dialogs down.

In OSX, you need to edit the .bash_login file in your user directory. A simple nano ~/.bash_login will allow you to edit the file (replacing nano is your own favourite editor).

To add IronRuby to your path add:

export PATH=/Users/Ben/Library/ironruby-0.9.3/bin:$PATH

Import points:
1) The path to your IronRuby bin folder.
2) Ensure you add the existing $PATH to the end
3) Export the result to the current PATH variable. Note, this is case sensitive.

To add jRuby you do it in a very similar fashion. However, because of priorities and how jRuby works, unless you want jRuby to be the default, add it to the end of the path export

export PATH=/Users/Ben/Library/ironruby-0.9.3/bin:$PATH:/Users/Ben/Library/jruby-1.4.0/bin

You should now be able to see all your ruby interpreters.

Ruby_OSX.png

A sneak peek at Meerkatalyst.Lonestar

Sunday, December 20, 2009

As I had some free time on my hands today I decided to create a new project called Lonestar. For those of you who are interested, here is the first (working) screenshot. Can anyone guess what it is?

Meerkatalyst.Lonestar Hello World Screenshot

For those of you who are following me on twitter then you will know I’ve been mentioning Meerkatalyst for a while – all will become clear soon. For now, keep an eye on my blog, the Meerkatalyst website and twitter feeds (@ben_hall and @meerkatalyst) for more exciting news on Lonestar and other projects!

Labels: ,

More amazing region examples

Friday, December 11, 2009

Come on – really?

image 

With the code being

image

This is why I hate regions

I just loaded up a default from Microsoft built into the Visual Studio 2010 extensibility and was greeted with this:

image

If someone could tell me what this region is actually adding to the code-base then I would love to know! Personally, it’s just a pointless layer of abstraction.

If your interested in what is happening within the region, well it gets worse. This is the code:

image

Instantly, I notice the following problems:

1) The comment to code ratio is very high. This makes seeing the code harder.

2) The attribute to code ratio is very high. This makes seeing the code harder, however it does have some useful information.

3) The class name is not at all related to the file name. This can cause real confusion when attempting to navigate and understand a code-base. Please, don’t do it.

What would happen if we wrote code like this:

image

The true intent of the code is now very clear without having to read anything! Stop hiding code and just show us the true aim.

Ideally I would also want to remove editorAdornmentLayer however MEF uses this, as such I need to leave it.

Labels:

Excellent error message from Amazon

Thursday, December 10, 2009

Yesterday I tried to purchase a book from Amazon UK on my iPhone and was given this error message:

IMG_0196

It had all my information, everything looked correct but unbeknown to everyone, including Amazon, it was game over.

Labels:

Making Visual Studio more keyboard friendly – File.Close

Saturday, December 05, 2009

image

Any time my hands are not on my keyboard my productivity is being harmed. Visual Studio + ReSharper has some really nice keyboard shortcuts which means I don’t need to use my mouse. However, one shortcut which just feels to me plain forgotten is being able to close a file using the keyboard. I can open, switch between but cannot close! Thankfully you can bind your own shortcuts, as such I bound to Ctrl+Q. Having this simply makes everything a little bit easier. But please, Visual Studio or ReSharper – auto-bind this command.

Note: Visual Studio 2010 Beta 2 is a bit buggy when it comes to keyboard shortcut. I had to un-assign anything bound to the key and restart the app before it took effect.

Labels: ,

Migrating from CodePlex to GitHub

While I have a lot of respect for the work Microsoft have done with CodePlex, personally I think GitHub is fundamentally a much better platform for open source projects. The main reason being is that it is just so easy to get access to the code, make changes and do whatever you want while utilising the power of Git. I have a couple of projects on CodePlex, so I wondered how easy it would be to port them over to GitHub.

After creating a new repository on GitHub, you are given the option to import from a Subversion Repository. All you need to do is enter the public Subversion URL for your repository.

image

Thankfully, CodePlex allows you to access your source code via TFS and Subversion. To find the URL, simply go to the Source Code tab and click Connection Instructions. This will give you the project’s SVN URL to enter into Github.

image

After clicking next the experience isn’t great – there is no real feedback about what is going on which is unfortunate.  However, after a while I received an email saying the Import had been completed successfully. If it fails, it also will send you an email to let you know.

image

My GitHub repository now has all the source code from my CodePlex project.

image

Along with the code, it also has all the commits and history associated with the project which is pretty awesome!

image

In just a few clicks I was able to migrate from CodePlex and SVN to GitHub and Git.

If you didn’t want to use the UI, or it failed for some reason, GitHub have a great guide about how you can do this import manually.

Labels: , ,

RubyMine – The Meta keyboard shourtcut on Windows

Saturday, November 21, 2009

Today I installed RubyMine 2.0 which is a great IDE from JetBrains. However, I was confused as all the keystrokes referred to ‘Meta’, for example ‘Meta+C’ for copying. Being on Windows 7, this wasn’t a valid keystroke.

After a bit of search around, it turns out RubyMine has keystrokes targeted for different environments, in my case it was targeted to be the same as TextMate. Awesome when I’m on my Mac, not so good on Windows.

To change the keymapping, select File > Settings. Pick the keymap option, and in the dropdown change it to Visual Studio.

image

Everything will then feel right at home.

Labels: ,

I've written a book on Testing ASP.net Web Applications

Thursday, November 19, 2009

If you have been following me on twitter then this will be old news however I realised I never announced it on my blog.

Well, here is it! I have written a book on Testing ASP.net Web Applications! The website for which can be found at http://www.testingaspnet.com/

Testing ASP.net Web Applications cover

I agreed to co-author the book with Jeff McWherter at PDC08 almost a year ago. Now, after a long hard year of constant work on both of our parts, I'm pleased to say that the book is now available on both Amazon.com and Amazon.co.uk.

The book provides the reader with an introduction into the main issues faced when testing ASP.net web applications, both WebForms and MVC. We wanted to provide a guide covering the various different issues you will face during the development and testing lifecycle.

The chapters are:
Chapter 1: Preliminary Concerns
Chapter 2: Design and Testability
Chapter 3: Unit Testing and Test Driven Development
Chapter 4: Integration Testing
Chapter 5: Automated UI Testing
Chapter 6: Acceptance Testing
Chapter 7: Manual Testing
Chapter 8: Performance Testing
Chapter 9: Accessibility Testing
Chapter 10: Security Testing

As proof that the book does actually exist, the amazing Betsy Weber spotted the book on the Wiley stand at PDC09.

Testing ASP.net Web Applications @ PDC09

If you happen to spot the book anywhere, or if you have read a copy and have feedback then please do let us know! We would love to hear from you!

Since completing the book, I've taken a break, joined 7Digital.com and started working on a number of other projects. Exciting times!

Labels: ,

Welcome to GitHub - Your first git repository

Wednesday, November 18, 2009

I've been using GitHub for a while now as it's a great way to share ideas and code in the public domain. Recently, I've had a number of people ask me how they can get started using GitHub. Thankfully, GitHub is an extremely simple service to use!!

Firstly, GitHub is a social coding repository, building on top of git (a source control system) to encourage collaboration on code and open source projects. By having this aim, the site is organised in such a way to make it very simple to upload code, as well as add additional contributors to the project. GitHub also has paid for accounts offering private repositories and additional features.

First, to use GitHub you need a git client installed. If you are on OSX, I recommend using the git-osx-installer while if you are on windows I suggest the MSysGit project. From my experience, I've found these to be the most effective way to start using git.

After signing up for a free account on GitHub, you need to create a public key. The next stage is to create a public repository to store code.

All you need to do is enter a name for a new repository, a description and click Create. Each project has it's own repository, unlike with other source control systems such as SVN.

GitHub_Create.png

After clicking create, you have your repository. GitHub provides you with the next steps about how you can add code in your public repository. A great way to learn the fundamentals of git at the same time.

GitHub_ReproCreated.png

The first command you will need is 'git init', this creates your local repository to store your project. Once you have a local repository, you can do all the standard commands you would expect such as git add, git commit, branch etc.

After you push your code to github, everyone will be able to view, clone, fork your repository. A great way to allow others to collaborate on your project. In my case, the repository I created was http://github.com/BenHall/SimplyRubyServer/.

As you start using GitHub and Git more and more, you will really understand how powerful they are.

Labels: ,