0

Along with a basic doubt I had here(which unfortunately did not get much attention) I have another basic doubt in context with preparing a Java Framework for Selenium-WebDriver. I am not satisfied with the answers here and need some quality advice on best practices from real world case scenarios. (Counting on SO)

The main question is - Which one is better suited for Selenium? TestNG or JUnit? And Why?

I got some basic differences here,here(for Automation but unclear answers -all ask to pick one) and many more. Looking for some more details which will help me decide better.

P.S: I have experience with Selenium+JUnit. Will I regret if I go the same way?

Community
  • 1
  • 1
some_other_guy
  • 3,364
  • 4
  • 37
  • 55

2 Answers2

2

simplicity with JUnit vs. adjustability with TestNG - that's all

Firstly, both work quite well.

If you want to scale down your execution time and have enough time to find out the best possible configuration I would recommend TestNG. In case of parallelization that's your tool

If you prefer the plainness of a top down execution JUnit is what you're looking for

--EDIT--

Regarding JUnit 3

Franz Ebner
  • 4,951
  • 3
  • 39
  • 57
  • Ah! Frank!! Well which one do you use for your Selenium Tests?? – some_other_guy Sep 04 '12 at 07:07
  • Previous JUnit and now TestNG... as I said TestNG needs some research if you want to use the enhancements, but it is very well documented. You can also use it like JUnit- just top down execution – Franz Ebner Sep 04 '12 at 07:10
  • Why did you shift from JUnit to TestNG? I am actually looking for answer to such questions. – some_other_guy Sep 04 '12 at 07:13
  • For simple Selenium testing is TestNG required? But I need a robust framework which we intend to maintain for a long time. And which framework is better for non-coder who might need to update locators etc? – some_other_guy Sep 04 '12 at 07:20
  • 1
    The best for non- coders who want to start testing is either learn to code or test manually. I switched because of horizontal scaling. – Franz Ebner Sep 04 '12 at 07:41
0

I'm in the process of switching from JUnit to TestNG with a project right now. It started as an experiment until switching over completely became a 'done deal' in my mind. Some things that sold me on it are the ability to easily tag tests (groups), easily create dependencies (don't run test y unless test x succeeds first), more robust out of the box reporting (robust may not be the right word, but I find them much easier to read and manage) and just more whizz-bang options in general, easily available and extendable. I'm early in the process and may yet come to regret it and switch back, but unless there's some major unforeseen disaster lurking in the road ahead I don't think so. If you do make the switch, look up the Eclipse plugin. Apply it to an existing test and be sure and take out any references to JUnit. You'll have to do some polishing and tweaking here and there, but it's no big deal once you get going.

Also bear in mind that the stock asserts have the same names as JUnit assertions, but the order of expected and actual values is opposite between the two. Dig in a bit and you'll see what I mean. Again, no big deal, just need to be aware of it.

Best wishes with whichever you choose. You can make either do what you want, I'm just finding TestNG a bit more flexible and...pleasantly surprising, which is nice to experience now and then in Java land! ;)

SkipKent
  • 457
  • 1
  • 6
  • 13
  • I've become less excited about the grouping options, aside from using them for dependencies which all by itself is great. I was originally hoping to use them much in the way I did at another company where we used Robot Framework, and easily kick off different sorts of tests at the command line while including or excluding various groups ('tags' in robot). In practice this started to feel more unwieldy than was worthwhile, and I've since gone back to creating simpler xml suites and just listing whatever classes I want in that suite. – SkipKent Oct 08 '14 at 14:25
  • I love the reporting and have since upgraded to ReportNg which is nicer still. I'll be implementing a screenshot-on-failure mechanism soon and we'll see how this compares to the experience with JUnit. – SkipKent Oct 08 '14 at 14:27