How easy is code verification?

I learn Java by reading "Head First Java" and doing all the puzzles and exercises. In the book, they recommend writing TestDrive classes to test the code and clans that I wrote, which is one very simple thing, but by doing this I think I can not fully test my code because I write test code knowing what I want get, I don’t know if it makes sense, but I was wondering if there is a way to check my code in a simple way so that it tells me that it does not work correctly. Thank.

+5
source share
7 answers

What do we mean by code? When testing the module that I'm thinking of here, we test specific methods and classes.

, ,

, , - . :

 int getInvestvalue( int depositCents, double annualInterestRate, int years) {

 }

? , . :

  deposit 100, rate 5.0, years 1 : expected answer 105
  deposit 100, rate 0, years 1 : expected answer 100
  deposit 100, rate 10, years 0 : expected anwer 100

? ?

, , 1,000,000.50 100,000 , , - , - ?

: . , , , , :

  • : , , , . 5%. . , , , - ...
  • : . . - - , : , "" .
  • : . . , yoiu , " ", .
+2

- , , , . - , , , , .

: , (.. n ) , .

- , - , .

, , , , .

, , , , , .

PS. , - , , , , , , , , , , .

: .

+4

"Test Driven Development" (.. , ). , ( ). , , . , , , .

, , jUnit, , - (.. , ). , ..

, , . , , .

+1

-, , . (, , ), unit test, . , , , , , , .

, , , , . , , , : ", ...", , . , , .

, , , QuickCheck , , , .

+1

TestDrive

, JUnit TestNG.

0

, . , . . , , , , .

, , , , - , , , ( !).

Pair Programming - . , , - -, ( ).

0

All Articles