Here, we will briefly introduce the concept of cell testing for j2ecunit. Many Reflection-based functions cannot be used because the j2ecs-based environment does not provide Reflection APIs, for example, the function of automatically creating and running testsuite in JUnit.
Introduction to cell testing for j2-unit:
Using unit testing frameworks such as JUnit for unit testing is no stranger to Java Programmers. Using these very effective tools, the quality of code can be effectively monitored and maintained. However, it seems that everything is slightly different on the j2's platform. Because the j2-based environment does not provide Reflection) API, many Reflection-based functions cannot be used, such as automatically creating and running the testsuite function in JUnit. The majority of j2s programmers cannot use JUNIT for unit testing on the j2s platform, but everyone knows how fragile a program without unit testing is!
The j2-unit Unit test is a Unit test framework designed and developed by KentBeck and ErichGamma to imitate JUnit, with a size of 17 kb. Its application provides basic support for compiling well-secured Java program code. Several new mechanisms have been introduced in the j2ecunit Unit test to solve the reflection dependency of the original JUnit. In use, it may be obvious that the j2unit Unit test is not as convenient as JUnit, but we can only use it at this stage, and we are eager to support reflection in the j2s environment. The current version of the j2unit Unit test is 1.1.1. Like JUnit, it is also open-source. You can find its download on sf.net. Compared with JUnit, The j2unit Unit test has not been upgraded for a while. On the one hand, the investment is relatively small, and it may be due to the particularity of the j2it environment, make sure that the LIB to be tested is small enough.
Set up a j2_unit Test Platform:
We use Eclipse with EclipseME as an example to illustrate how to use the j2-unit Unit test.
First download the latest version of the j2ecunit test from sf: http: // j2ecunit test .sourceforge.net and decompress it to your frequently used directory.
Create a MidletSuite and select Project...> Properties...> JavaBuildPath...> Libraries...> AddExternalJARs... Select the j2_unit Unit test. jar file in the download path.
In this way, you can use it.