ict.ken.be

 

Posts in Category: Testing

Selenium Unable to cast object of type 'System.String' to type 'System.Collections.Generic.Dictionary 

Categories: Testing

When using Selenium remember that if you are connecting to a linux grid the url for the remote driver is case sensitive.

Mostly when you get this error it is because the url to the grid is wrong !

eg. http://192.168.99.100:4444/wd/hub

System.InvalidCastException

Unable to cast object of type 'System.String' to type 
'System.Collections.Generic.Dictionary`2[System.String,System.Object]'.
 at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
 at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
at ken.Selenium.Errors.SeleniumTests.ShouldHaveNoJavascriptErrors(String url) in d:\Sources.Sandbox\Ken\ken.Selenium.Errors\...\SeleniumTests.cs:line 79

xunit nuget - A numeric comparison was attempted on - Error 

Categories: Testing

Was trying to add xunit 2.1.0 nuget to my solution and I received this strange error containing : "A numeric comparison was attempted on ..."

I had to disable resharper, restart visual studio and enable it again before my solution would build again.

  • Tools > Options > Resharper > Suspend Now / Resume Now

Weird.

Wallaby 

Categories: Testing

It's like NCrunch but for javascript.

http://wallabyjs.com/

JS Testing History

  • console
  • browser running tests
  • commandline with test watcher (needs stack copy)
  • resharper running tests (needs reference paths)
  • wallaby coverage and running tests

Wallaby

  • install through extensions
  • add wallaby.json to your solution

wallaby.json

{
  "files": [
    { "pattern" : "test/lib/chai.js", "instrument": false },
    "src/*.js"
    ],
    "tests": [
        "test/*Tests.js",
        "test/*Tests.ts",
        "test/*Tests.coffee"
    ],
    "testFramework": "mocha"
}
  • default test framework is jasmine
  • to exclude from coverage set instrument to false
  • right-click wallaby.json and select start
  • restart wallaby if you update the wallaby.json
  • yellow means partially covered (click to see what part was not processed)
  • screenshot of last runned test in context menu

Wallaby Visual Studio Shortcut Keys

  • Start Wallaby: alt-w alt-1
  • Stop Wallaby: alt-w alt-2
  • Restart Wallaby: alt-w alt-3
  • Run all tests: alt-w alt-4
  • Jump to failing test: alt-w alt-5
  • Context Menu: alt-shift-f10

Advanced

wallaby.js

var babel = require("babel");

module.exports = function (wallaby) {
    return {
        "files": [
            { "pattern": "test/lib/*.js", "instrument": false },
            "src/*.js"
        ],
        "tests": [
            "test/*Tests.js"
        ],
        "delays": {
            edit: 700,
            run: 300
        },
        "debug": true,
        "compilers": {
            "**/*.js": wallaby.compilers.babel  (
                {
                    babel: babel,
                    stage: 0
                }
            )
        },
        "env": {
            type: "node"
        }
    };
}

More

The Joel Test 

Categories: Testing
  1. Do you use source control?
  2. Can you make a build in one step?
  3. Do you make daily builds?
  4. Do you have a bug database?
  5. Do you fix bugs before writing new code?
  6. Do you have an up-to-date schedule?
  7. Do you have a spec?
  8. Do programmers have quiet working conditions?
  9. Do you use the best tools money can buy?
  10. Do you have testers?
  11. Do new candidates write code during their interview?
  12. Do you do hallway usability testing?

Read more at JoelOnSoftware or get the book Smart and Gets Things Done by Joel Spolsky

Viewresult into html, best error ever. 

Categories: Testing

Some time ago I was converting MVC ViewResult into html to use in some mocked integration tests and this is the nice error I got. Wonderful. Anyway, just wanted to post the screenshot because I think it is better to substitute part of the environment instead of trying to mock all this stuff. I strongly believe in end-to-end testing with tools like Selenium. Not that there is anything wrong with using mocks when testing 3rd party vendor api...

Screenshot of runtime error

Page 1 of 2 1 2 > >>