WEBVTT 1 00:00:00.222 --> 00:00:02.223 The Room class has now been refactored 2 00:00:02.224 --> 00:00:05.003 to use an ArrayList to store its items 3 00:00:05.004 --> 00:00:06.223 rather than an array. 4 00:00:07.111 --> 00:00:10.229 In this demo I'm going to test the refactored Room class 5 00:00:11.229 --> 00:00:15.001 refactoring improves the way a class is implemented 6 00:00:15.112 --> 00:00:18.112 but doesn't add any new capabilities to the class. 7 00:00:19.224 --> 00:00:23.001 In the previous increment I created a JUnit test class 8 00:00:23.003 --> 00:00:27.114 and test method to test the functionality of the room class 9 00:00:28.008 --> 00:00:31.002 since that functionality shouldn't have changed at all 10 00:00:31.008 --> 00:00:33.226 I should be able to rerun exactly the same test 11 00:00:34.000 --> 00:00:36.005 and it should still pass that test. 12 00:00:37.007 --> 00:00:38.114 So let's do that 13 00:00:38.221 --> 00:00:41.002 I could use the run test button as before 14 00:00:41.006 --> 00:00:43.111 to run all the tests in the project 15 00:00:43.227 --> 00:00:46.006 or since I'm just testing the room class here 16 00:00:46.007 --> 00:00:49.220 I can use the right click menu option in RoomTest 17 00:00:50.000 --> 00:00:51.117 to test all, that will run all the 18 00:00:51.118 --> 00:00:53.228 test methods in the RoomTest class. 19 00:00:54.008 --> 00:00:55.115 So I do that 20 00:00:55.116 --> 00:00:58.000 the test window opens, I have a green bar 21 00:00:58.005 --> 00:00:59.227 and that shows that the refactored version 22 00:00:59.228 --> 00:01:02.224 of the Room class still passes the same test 23 00:01:02.227 --> 00:01:04.226 as the original version did. 24 00:01:05.111 --> 00:01:08.112 So I can be confident that in refactoring the room class 25 00:01:08.114 --> 00:01:11.008 I haven't removed or broken any of the functionality 26 00:01:11.009 --> 00:01:12.117 it had originally. 27 00:01:14.002 --> 00:01:15.008 As I mentioned before 28 00:01:15.009 --> 00:01:19.002 I've only written one example test method in my test class 29 00:01:19.225 --> 00:01:21.111 to test a class thoroughly 30 00:01:21.117 --> 00:01:23.000 you should write test methods for 31 00:01:23.001 --> 00:01:25.228 all the significant functionality in that class. 32 00:01:26.226 --> 00:01:29.118 Automated unit testing makes it very quick and easy 33 00:01:29.119 --> 00:01:32.000 to fully test the functionality of a class 34 00:01:32.005 --> 00:01:33.229 where all the classes in your project 35 00:01:34.002 --> 00:01:36.002 each time you refactor.