Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Lab: JUnit Testing Pattern Lab: JUnit Testing Pattern Objective In this lab you will learn how to organize a JUnit test fixture so that it can be easily reused for different implementations. Setup Follow these steps to set up a project for this lab. Create a new Eclipse project by copying ProjectTemplate. Name the new project JUnitTestingRevisited. Create a new JUnit test fixture by following these steps: Right-click on the test folder in your project and select New > Class; name the class StackTest and click Finish. Follow the link to StackTest.java, select all the code on that page (click and hold the left mouse button at the start of the program and drag the mouse to the end of the program) and copy it to the clipboard (right-click the mouse on the selection and choose Copy from the contextual pop-up menu), then come back to this page and continue with these instructions. Open the StackTest.java file; select all the code in the editor, right-click on it and select Paste from the contextual pop-up menu to replace the existing code with the code you copied in the previous step. Save your file. Repeat the steps above to create another class in the test folder, name it Stack1LTest, and replace its contents with the code from Stack1LTest.java Method Take a look at the two classes provided and make sure you understand how they are organized. Complete the body of the createFromArgsTest and createFromArgsRef methods in StackTest.java so that they satisfy their contracts, and the body of the constructorTest and constructorRef methods in Stack1LTest.java so that they instantiate and return stacks of type Stack1L and of type Stack3, respectively. Note that the varargs argument to createFromArgs can be interpreted and accessed as an array (guaranteed not to be null). Run the Stack1LTest JUnit test fixture and make sure that all test cases complete successfully. If any of the test cases result in failures or errors, that probably indicates a problem with your code for the methods you implemented. Once everything works as expected, create a new class in the test folder, by copying and pasting Stack1LTest, and name it Stack2Test. Update the constructorTest method so that it instantiates and returns a stack of type Stack2 (you can keep Stack3 as the reference implementation). Run the Stack2Test JUnit test fixture and make sure that all test cases complete successfully. This shows how simple it is to reuse the StackTest fixture to test a different implementation of Stack. Consider the first section of test cases in StackTest, where we provided a few examples of test cases for the Stack kernel methods. Add new test cases to this section of StackTest to test thoroughly and systematically the kernel methods push, pop, and length. Run the test fixtures and make sure all your test cases succeed.