1. Unit Test
1.1………………………….Approach
1.2………………………….100% Code coverage test cases
1.2.1…………………..TestCase-1
1.2.2…………………..TestCase-2
1.2.3…………………..TestCase-3
1.2.4…………………..TestCase-4
1.2.5…………………..TestCase-5
1.2.6…………………..TestCase-6
1.2.7…………………..TestCase-7
1.2.8…………………..TestCase-8
1.2.9……………...….TestCase-9
1.2.10………………....TestCase-10
1.3………………………….Additional Test Cases for Data Coverage
1.3.1…………………..TestCase-1
1.3.2…………………..TestCase-2
1.3.3…………………..TestCase-3
1.3.4…………………..TestCase-4
1.3.5…………………..TestCase-5
1.3.6…………………..TestCase-6
1.3.7…………………..TestCase-7
2. Defects
2.1………………………….Defects
3. Others
3.1………………………….Sources
1.Unit Test
Goals and objective of unit test:
Unit test are done to check whether a particular module or unit of code is working fine. It eliminates all logical and runtime errors. It is particularly useful for testing code at the most basic module to ensure any errors don’t percolate up to the modules up in the hierarchy. A main objective of unit testing is to achieve 100% code and data coverages.
100% code coverage is achieved by analyzing expectations of individual methods and producing test cases to meet each of those requirements. Actual implementation of code can also taken into account to achieve more code coverage. Exception handling is also covered in this part.
For data coverage, we take all extreme end values (INT_MAX,INT_MIN) and XXXXXXXX values XXX testing XX results for rest of XXX values XXX XXXXXXXXX.
XXX instance of XXXXXXX data values can XX XXXXX XX XXXXXXX don’t XXXX for rest XXXXXX. Illegal data values/XXXX/empty XXX XXXX tested to check if XXXX rejects XXXX XX XXXXXXXX. We XXXXX only XXXX XXXX at least XXX XXXXXXXX of all kinds of XXXX XXXXXX XXX XXXX XXXXXXXX in our XXXX XXX. Uninitialised XXXXXX XXX XXXXXX XXX XXXXX default XXXXXX, XXXX an XXXXXXXXXXXXX integer is tested for a XXXX value.
XX case XX exception XXXXXXX, a XXXX XXXX is of form “testMethodNameException”
XX XXXX of XXXXXXXXX checking, test case XX of XXXX “testMethodNameAttr_AttrName”
These naming conventions XXXX XX to clearly XXX which XXXXXX XXX XXXXXXXXX of XXX XXXXXX is being tested just XX looking XX XXX test XXXX.
XXXX XXXX XXXXXX would XX a single XXXX case, so that XX clearly know XXXXX test XXXXX fails.
XXX there should XX a single XXXXXX per method. This XX XXXXXXX XXXX an XXXXXX XXXXX, XX don’t XXXX XXXX XXXXXXX in front XX us to decide which one XXXXXX. There XXXXXX XX XX least XXX assert/XXXX statement in XXXX method else XXXX XXXX would XXX XXXX fail. XXXX, XXXXX can be XXXXXXXX fail XXXXXXXXXX within a method, XXXXXX assert. All test XXXX XXXXXXX match XXXXXX declaration in code.
XXX XX you XXXX you are done XXXXXXX? :
When you have XXXXXXXX all XXXXXXXX inputs XXXX a module can XXXX XXX the XXXXXX XXXXX XXX expected results. XXXXX an XXXXXXXXX XXXXXX XX all XXXXXXXX inputs XX XXXXX to XXXX time XXX XXX XXXX tests in XXXXXXXXXX time. XXX corner XXXXX XXX XXXXXXXX XXXXXX must also XX XXXXXXXX in test XXXX.
XXXX kind of testing is XXXX test (XXXXX-XXX, XXXXX-XXX, XXXXXXXX, XXX.) and XXXX sure to explain what XXXX type XX XXXXXXX does?
Black XXX XXXXXXX XX done when only XXX XXXXXX XX XXXXXXX XXXX XX XXXXX tested. The internal structure XX code XX not XXXXX XXXX XXXXXXX. White box XXXXXXX XX done XXXX you want XX check XXX XXXXXXXX variables/methods as well. The XXXXXX code structure XXX all XXXXX/global variables XXX XXXXXXX XXX XXXXX XXXX account XXX XXXXXXXX.
Unit XXXXXXX can XX XXXX in both XXX ways.
What are XXXX XXXXXXXX XXX XXXX coverage and how XXXX XXXXXX XX XXXX XXXX?
XXXX XXXXXXXX refers to the lines/XXXXXX XX code XXXXX exercised by XXXXXXXXXX XXXX XXX. Data XXXXXXXX XXXXXX to the span XX test data XXXX XX are able XX cover XX deploying a XXXXXXXXXX XXXX XXX.
XXXX reference to unit test, we XXXX maximize both code coverage and data XXXXXXXX. XXX% XXXX coverage XX often XXX possible so XX XXXX optimize XXX XXXX data to XXXX XXXXXXXXXX XXXX coverage while XXXXXXX in XXXX a XXXXXXXXXX runtime XXX the tests.
What XXX XXXX characteristics XXXX you XXXXXXX XXXXX in XXXX 3 of this course? XXXX them XXX XXXXXXX in your own words:
XXX XXXX test XXXXXXXXXXXXXXX learned in XXXX 3 XXX XX XXXXXXX:
Fast: Unit tests should XX able to XXX quickly.Independent: XXXX tests should be separate from one XXXXXXX. This XXXXXX them XX XX XXX in XXX order.Repeatable: XXXX tests should be able XX XX XXXXXXXX in any XXXXXXXXXXX.Self-validating: XXXXX XXXXX XXXXXX XXXXXX just XXXX or XXXX.XXXXXX: XXX unit XXXXX XXXXXX not XXXX an extended XXXXXX XX XXXX to write.XXXXXXXXX: XXXX tests XXXXXX be able XX run XXXXXXXXXXXXX. You XXXXXX be able to XXXX in one XXXXXXX or simply XXX a XXXXXX XXX XXX the XXXXX. This also means that the XXXX should be able to determine, on XXX own XX it XXX XXXXXX or passed. You should XXX XXXX to read XXXXXXX XXXX long XXXXXX to XXXXXX out XX it XXXXXX or not.XXXXXXXX: XXXX simply means that a XXXX XXXX XXXXXX test anything XXXX you believe XX XXXXX XX XXXXX. If you think it could go XXXXX: XXXX it. XX course, you can’t XXXXXX XXXX absolutely everything, so you XXXX use XXXX XXXXXXXXX XXXXX XX XXXX XXXXXXX’s needs.Repeatable: XXX XXXXX XXXXXX be able to XXX XXXX and over in XXX order needed XXX XXX XX XXXX the same results. XXXX tests XXXXXX essentially be independent XX environment. XXXXX XXXX XXXX XXXXX you to XXXXXX XXX unit test in any XXXXXXXXXXX XXXXXXX issue.XXXXXXXXXXX: Unit tests XXXX XX XX kept independent XXXX XXX XXXXXXX. This XXXXX that tests XXXXXX not XXXX to XXXX on XXXXXXX in order XX XXX. They XXXXXX also be independent XX the XXXXXXXXXXX. This XXXXXX XXXX XX run the XXXX tests XXXXXXXX XXXXXX. It’s also possible XXXX XXXXX XXXXXXXXXX XXX need XX XXX the tests at XXX same time, so independence XX important.Professional: XXXX means that the XXXX XXXXX you write should XXXXXX XX XXX XXXX standards as your XXXXXXXXXX XXXX. XXX XXXXXX apply XXX XXXX XXXXXXXXXX XX good design XXX XXXXX XXXX to XXX XXXX tests.
XXX normally writes and executes unit XXXX?
White XXX unit XXXXXXX XX XXXX XX developers XXXXXXXXXX. Whereas black box XXXX testing can XX XXXX XX separate XXXXXXX. More XXXXX both XXX XXXXXXX XX XXXX XX XXX developers themselves.
XXX XX you determine that a XXXXXX has been XXXXX in UT?
XXXXXXXX, XXXXXXX assertion statements are used XX perform XXXXXXX. Failure XX XXXXXXXXX is XXXXXXXX in logs XXXXXXXX XXX XXXX assertion XXXXX. Logs generated XXXXX running the XXXXX should XX carefully examined.
As XXXXXXX are found during unit XXXX who XXXX fixes them?
The test XXXXXXX XXX directed XXXX to the XXXXXXXXXX (in XXXX someone XXXX XXX the XXXXXXX) XXXXXX XXXXXXXXXX and XXXXXX-XXXX checks are XXXXXX in the code XX XXXXXX the bugs encountered.
What XXXXXXX next XXXXX defect XX fixed in the XXXX XXXXX tested?
XXXX the XXXX is fixed the XXXX tests XXX XX-XXX, if there XX any significant XXXX XXXXXXX XXXXX XXXXXX the bug, we must incorporate more XXXX cases in XXX XXXX data XX XXXXXXX increase XXX XXXX coverage.
1.X
XXX% Code XXXXXXXX XXXX XXXXX
X.2.X XXXX Case 1
XXXX case XXXX: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Method being XXXXXX: XXXXXXXXXXXXXXXXXXXX()
Short Description: check if XXXXXXXXXXX is XXXXX initialized XX XXXXX on object XXXXXXXX
Input Data to constructor and/or XXXXXX you XXX XXXXXXX: no inputs
XXXXXXXX XXXXXXX:XXXXXXXXXXX =PRINT
X.2.X Test Case 2
XXXX case name: XXXXXXXXXXXXXXX
XXXXXX XXXXX tested: XXXXXXXXXXX()
Short Description: check if XX XXX XXXXXXXX correct XXXXX of attribute XXXXXXXXXXX
Input XXXX to XXXXXXXXXXX XXX/or method you XXX testing: XX inputs
Expected XXXXXXX:currentFunc =XXXXXXXX.XXXXX
X.X.X XXXX Case X
XXXX XXXX XXXX: TestGetPages
Method XXXXX tested:getPages()
Short XXXXXXXXXXX: XXXXXX XXXXXXX we XXX retrieve correct XXXXX XX pages
XXXXX Data to XXXXXXXXXXX XXX/or method you XXX testing:XX inputs (as XXXXX XXXX have XXXX XXXXXXXXXXX XX zero, so we will check that)
XXXXXXXX XXXXXXX:XXXXX=X
1.X.4 XXXX XXXX 4
XXXX XXXX XXXX: XXXXXXXXXXXXXXXXXXXXXXXX
XXXXXX being tested:XXXXXXXXXXX(XXXXXXXX f)
XXXXX Description: to check XX the XXXXXXXX XXXXXX an IllegalArgumentException XXXX XXXXXX XXXXXXXX is not equal to XXXXX/XXXX
Input XXXX to XXXXXXXXXXX and/or XXXXXX you XXX XXXXXXX:f=XXXXXXXX.XXX
XXXXXXXX XXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXX(“Function XXX only be PRINT or XXXX”)
X.2.X Test Case X
Test case XXXX:TestSetFunctionAttr_currentFunc
XXXXXX XXXXX XXXXXX:setFunction(XXXXXXXX f)
Short Description: to check XX the function XXXXXXXXX XXXXXXX the value currentFunc = f
XXXXX XXXX XX XXXXXXXXXXX XXX/or XXXXXX you are testing:f=XXXXX
XXXXXXXX Results:currentFunct=XXXXX
X.2.X Test Case X
Test case XXXX: TestSetPagesAttrPages_whenParameterLessThanZero
XXXXXX being tested:setPages(int p)
Short Description: to XXXXX XX the function XXXXXXXXX XXXXXXX attribute pages=X XXXX passed XXXXXXXXX p&XX;0
Input XXXX to XXXXXXXXXXX and/or method you XXX testing:p= -XX
Expected Results:XXXXX=X
1.X.7 Test XXXX X
XXXX case name: TestSetPagesAttrPages_whenParameterIsNonNegative
Method being XXXXXX:XXXXXXXX(int p)
XXXXX Description: to check if XXX XXXXXXXX XXXXXXXXX assigns attribute XXXXX=p when XXXXXX XXXXXXXXX is XXX negative
XXXXX Data XX constructor XXX/or method you XXX XXXXXXX:p=5
Expected XXXXXXX:p=X
1.X.X Test Case 8
XXXX XXXX name: TestSettingsException
XXXXXX being tested:settings(Function f, int p)
XXXXX XXXXXXXXXXX: to XXXXX XX settings method throws XXXXXXXXXXX exception when f is not XXXX/PRINT
Input XXXX XX constructor XXX/or method you are testing:f=XXX,p=X
Expected Results :IllegalArguementException(“Function XXX XXXX XX PRINT or COPY”)
X.X.9 Test XXXX 9
Test case name: XXXXXXXXXXXXXXXXXXXXXX
XXXXXX being XXXXXX:XXXXXXXX(Function f, XXX p)
Short Description: to XXXXX XX XXXXXXXX method correctly assigns XXXXX = p
XXXXX Data XX constructor XXX/or XXXXXX you XXX testing:f=COPY,p=5
Expected Results:pages=5
1.2.XX Test Case XX
XXXX case XXXX: TestSettingsAttr_currentFunc
Method XXXXX tested:settings(Function f, int p)
XXXXX Description: XX check if settings method XXXXXXXXX XXXXXXX currentFunc = f
XXXXX XXXX to constructor and/or method you XXX testing:f=XXXX,p=5
XXXXXXXX XXXXXXX:currentFunc=XXXXXXXX.COPY
XXXX XXXX name: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Method being XXXXXX: setPages(int p)
Short Description: XX check if pages=X when currentFunc XX XXX XXXXX/COPY
XXXXX XXXX XX XXXXXXXXXXX and/or method you are testing: p=5 (XXXXXXXXXXX XXX to FAX)
Expected Results: pages=X
X.3.2 Test XXXX X
Test case name: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Method being XXXXXX: setPages(int p)
XXXXX XXXXXXXXXXX: XX check if XXXXX=X at critical value p=X
XXXXX XXXX to XXXXXXXXXXX XXX/or method you XXX XXXXXXX: p=0
XXXXXXXX XXXXXXX: XXXXX=0
X.3.X XXXX XXXX X
Test case name:TestSetPagesAttr_pagesMAX_VALUE
XXXXXX being XXXXXX:setPages(XXX p)
XXXXX XXXXXXXXXXX: to XXXXX XX pages=Integer.MAX_VALUE XX XXXXXXXX XXXXX p=MAX_VALUE
XXXXX XXXX XX constructor XXX/or method you are testing:p=Integer.XXXXXXXXX
XXXXXXXX XXXXXXX: XXXXX=Integer.MAX_VALUE
X.X.4 XXXX Case X
XXXX XXXX name:TestSetPagesAttr_pagesMIN_VALUE
Method XXXXX XXXXXX:setPages(XXX p)
Short Description: to check if XXXXX=Integer.XXXXXXXXX at critical XXXXX p=XXXXXXXXX
Input Data XX XXXXXXXXXXX XXX/or XXXXXX you are testing:p=Integer.XXXXXXXXX
Expected XXXXXXX: pages=Integer.MIN_VALUE
1.X.5 Test Case 5
Test XXXX name:TestSettingsAttr_pagesValueZero
XXXXXX XXXXX XXXXXX:settings(Function f,XXX p)
Short XXXXXXXXXXX: XX XXXXX XX XXXXX=X at critical XXXXX p=0
XXXXX XXXX XX XXXXXXXXXXX and/or XXXXXX you XXX testing: f=XXXXXXXX.PRINT,p=0
XXXXXXXX XXXXXXX: XXXXX=0
1.X.6 Test XXXX X
Test XXXX XXXX:testSettingsAttr_pagesMAX_VALUE
XXXXXX being XXXXXX:settings(XXXXXXXX f,int p)
Short Description: XX check XX pages= Integer.MAX_VALUE XX critical value p= Integer.XXXXXXXXX
Input Data to constructor XXX/or XXXXXX you XXX XXXXXXX: f=Function.PRINT,p= Integer.MAX_VALUE
XXXXXXXX Results: pages= Integer.XXXXXXXXX
X.3.7 XXXX XXXX X
Test case XXXX: :XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Method being tested:settings(XXXXXXXX f,int p)
Short XXXXXXXXXXX: to check if XXXXX=Integer.MIN_VALUE at critical value p=XXXXXXX.XXXXXXXXX
Input XXXX to constructor XXX/or method you XXX XXXXXXX: : f=Function.PRINT ,p=Integer.XXXXXXXXX
XXXXXXXX XXXXXXX: pages=XXXXXXX.MIN_VALUE
X.
Defects
XXXX XXXXXXX XXXXX XXX XXXXXXXXXX XXXXXXX
X.1
Defects
2.X.X
Defect X
XXXXXX/Constructor:Put here the source method or constructor XXXX that has a defect
XXXXXX XXXXXXXXXXX: Put here, XXXX behavior is incorrect and why you XXXXXXX it’s a defect. What XXX XXXXXXXX XXXXXX XXXXXX XXXXXXXX?
How XXXXX:XXXXXXX how you XXXX able XX find XXXX defect and which test case (name XX XXXXXXXX) XXXXX the issue
X.X.2 Defect 2
Method/Constructor:XXX XXXX XXX XXXXXX method or constructor XXXX XXXX XXX a XXXXXX
XXXXXX Description: Put XXXX, what behavior is incorrect and XXX you XXXXXXX it’s a XXXXXX. What was XXXXXXXX versus actual XXXXXXXX?
How Found:XXXXXXX how you were able XX XXXX this defect XXX XXXXX test case (XXXX XX XXXXXXXX) XXXXX the issue
.…
X.
Other
X.1
Sources:
Junit tutorials:XXXXX://XXX.XXXXXXXXXXXXXX.XXX/junit/index.XXXXXXXX XXXXXX by XXXXXXXXXXX:https://www.youtube.com/watch?v=AN4NCnc4eZgCode XXXXXXXX :XXXX://tutorials.XXXXXX.XXX/java-XXXX-XXXXXXX/XXXX-coverage.htmlXXXX coverage overview:XXXXX://XXXXXXXXXXXX.com/blog/XXXX-XXXXXXXX/
">