I am writing Selenium Tests to test a web application written in .Net (C#) What are the advantages and disadvantages of writing tests in Java to te开发者_JAVA技巧st .Net code?
The upside of using Java would IMO be if you are more comfortable using the language or have test reporting tools, build environments or other infrastructual investments in the Java sphere already that you can take advantage of.
The downside would be that since the application you are testing is a C# application you need the maintainer to master 2 languages in order to change it.
When it comes to Selenium RC in itself, I'm not aware of any advantages using Java or C#.
Personally I find that the testers can work a lot closer with the developers when they use the same language as the developers.
You can also place the test code in a solution alongside the application code in the same source code repository. The developers can then run the tests as well if they like just doing a checkout, build and run the tests in the same IDE as they do their development.
Things like build integration, automated scheduling of tests should be smooth if you work in the language which is used to develop and maintain the application.
Generally speaking, you want your tests and applicaiton written in the same framework for the following reasons:
- Developer Competency the JVM and .Net are such huge environments that you would do well to really dig deep into one or the other. Having your tests look familiar to your app makes the transition easier.
- Sharing of tools The fewer different external tools you have to depend on the better.
- Native Application Calls It's less of a concern in Selenium tests, but you may at one point want to interact with the application directly, say through a WCF call, and using the same tools makes that easier
That said, it's not an automatic slam dunk. Some of the benefits of separate tools include:
- Language fit Dynamic languages get a lot of love for their ability to easily mock and test. You're bouncing between C# and Java, so that's less of a concern, but something like IronPython offers interesting opportunities.
- Tooling Support I've always though Java had the better test, build, integration story. Also, the Selenium APIs tend to get developed first in Java, then ported to new languages. However, unless you want to be right on the bleeding edge, the support is generally good enough between C# and Java
All in all, the languages are so similar it's not hard to jump between them, but if I were you I'd go with C# for tests.
精彩评论