This code inspects a
property with the help of ReflectionProperty and displays the following output:
===> The public property 'length' (which was declared at compile-time)
having the modifiers array (
0 => 'public',
)
Reflection and Unit Testing
[ 110 ]
---> Value is: int(5)
---> Setting value to 10, new value is: int(10)
object(String)#2 (1) {
["length"]=>
int(10)
}
We will see some more uses of Reflection API in later chapters, when we will learn
build an MVC framework.
Unit Testing
Another very important part of programming is unit testing, by which you can test
pieces of code, whether it works perfectly or not. You can write test cases against
any version of your code to check if your code works after refactoring. Unit testing
ensures the workability of the code and helps to pin-point the problem when it
occurs. When you code your application, unit tests works as your skeleton.
Unit testing is a mandatory part of programming for programmers of every
language. There are unit testing packages available for almost all major
programming languages.
As with every other programming language, there is one package for Java that
is considered as a standard model for every other unit testing package for other
languages.
Pages:
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125