c# - Is it a good practice to use RowTest in a unit test -
NUnit and MbUnit have a line feature that allows you to send different sets of parameters in a single test. [Zero (-5, 6, 1)] Public Zero AddTest (Double First Number, Double Second Number, Double Results) [Row (5, 10, 15)] [Row (3.5, 2.7, 6.2)] ) {Assert.AreEqual (Results, First Number + Second Number); }
I was a big fan of this feature. I used it everywhere, however, recently I am not sure that it is a good idea to use Route in the unit test. Here are more reasons:
One unit testing should be very simple. If there is a bug, you do not want to waste a lot of time to determine what your test tests are. When you use multiple rows, the set of parameters in each row is different and takes a different test.
In addition, I am also using, which allows me to run my unit tests from my IDE, Visual Studio. With TestDrivent.NET, I can not provide directions to run a specific line, it will execute all the rows. Therefore, when I debug, I should leave comments on all other rows and leave only one.
Here is an example of how to test my test today:
[test] Public Zero Add_with_positive_whole_numbers () {Assert.AreEqual (5, 10 + 15); } [Test] Public Zero Add_with_one_decimal_number () {Assert.AreEqual (6.2, 3.5 + 2.7); } [Test] Public Zero Add_with_negative_number () {Assert.AreEqual (1, -5 + 6); } To say that I still sometimes use the Rottest feature, but only when I feel that I do not need to work on it later, I slow down Is not going to happen.
Do you think this is a good idea to use this feature in a unit test?
Yes. / Strong> This is basically executing the same test with different inputs repeatedly ... saves you the hassle of repeating for each specific input combination.
Thus 'Once and Only Once' . So if you need to update this exam then you can update a test (versus multiple) tests.
Each line should have a representative input from a different set - that is, this input is different from all the other wrt. The behavior of this function ROVEST was actually a lot of questions for NUNIT- originating from MBUNET W ... I think Shlapsi wrote it as an NUINIT extension, which was later promoted to SDD distribution status. The unit GUI also shows all the lights group under a node in the GUI and indicates which input is unsuccessful / passed .. which is cold.
The slightest disadvantage of 'need to debug' is something that I can live with myself. After the temporary comment of all the line attributes (first time, I can take a look in a time when I'm getting the SINRX and resolves without one step) or vice versa. Copy and pass the test. This fixed (problematic) input temporarily
Comments
Post a Comment