A couple of additions to Mike Stone's reply:
std::swap()
is used by many std containers (such as std::list
and std::vector
) during sorting and even assignment.
1) The most frequent thing I use TestNG's groups for is when I want to run a single test method in a test suite. I simply add this test to the group "phil" and then run this group. When I was using JUnit 3, I would comment out the entries for all methods but the one I wanted to run in the "suite" method, but then would commonly forget to uncomment them before checkin. With the groups, I no longer have this problem.
But the std implementation of swap()
is very generalized and rather inefficient for custom types.
2) Depending on the complexity of the tests, migrating tests from JUnit3 to TestNG can be done somewhat automatically with sed and creating a base class to replace TestCase that static imports all of the TestNG assert methods.
Thus efficiency can be gained by overloading std::swap()
with a custom type specific implementation. But how can you implement it so it will be used by the std containers?