Unit testing: How to check if generated javascript (string) is valid javascript
For unit testing purposes: Im searching for testing framework like NUnit that can validate if a "javascript" is valid within the most common browsers (IE, FF, Chrome, Safari). The javascript will be automaticly created from an class.
Does someone know if there is a testing framework like NUnit for this, within cscharp (c#)? Ofcourse Im writing tests myself on the开发者_运维知识库 javascript so it should be good.
But I just want to be absolutly sure its valid.
This looks useful: http://madskristensen.net/post/Verify-JavaScript-syntax-using-C.aspx
Get a modified copy of jshint and run your generated code through to check whether it's correct. I'd probably use JS.NET 2010 for this or ironJS.
I would suggest using Selenium to actually run the Javascript in the supported browsers. It is easily used from any xUnit type testing framework and it supported by C#.
精彩评论