Test driver in JavaEE

Source: Internet
Author: User
Tags touch ruby on rails groovy script xunit

This month's project was to promote the Enterprise Java unit test in the R & D team, which is a comprehensive product of unit test and acceptance test. In Dalian in 2003, elian put forward with foresight that what we did was neither a white-box test nor a black-box test, but a gray-box test. Amazing. In practice, Fit, Selenium, dbunit, and many xUnit extensions have their own advantages and disadvantages.
 
I have read a number of xUnit books and have also practiced in projects. At that time, I was a bad temper boy who devoted himself to R & D, I am not very cooperative with the testing staff (but now many developers are not willing to mention the attitude towards the testing staff. If I had a bad temper, if I try to beat 100 and drag them out to feed the dog, I will be fascinated by demand management. Then I will find that the R & D method is: test Driven Development ).
 
With this open-minded experience, it is not in the C ++ development environment, nor in the development team of "Ji Eryi (J2EE, a customer's pronunciation, but when using Rails. Rails is so good that I don't want to elaborate on it here. One thing is that after you use Ruby on Rails, you basically don't want to touch a line of java code, especially after using rails for unit testing and functional testing. Rails's support for unit testing and functional testing is a must.
 
However, unlike me, most developers can easily switch to platforms other than J2EE, so they still need to perform unit test promotion under JavaEE. If anyone wants to tell me, use junit, I believe that there is basically no real write unit test. Due to the transition, a number of models and layers are adopted... It is not easy to push unit tests in the J2EE development team, not to mention the promotion in the teams of developers who feel "unit testing is what testers should do if they are exhausted and should not be miserable.
 
In fact, the path is mature, and the main problem is that no one is willing to work hard. The subline is: I would rather restart several servers for debugging, and I would rather reopen several bugs, and do not want to get in touch with new things. is this new? Does this really waste your precious time? It's really sad to be a programmer.
 
In fact, it's no wonder that you should take a look at a piece of java code:
Import java. util. List;
Import java. util. ArrayList;
Class Erase {
Private List filterLongerThan (List strings, int length ){
List result = new ArrayList ();
For (int I = 0; I <strings. size (); I ++ ){
String s = (String) strings. get (I );
If (s. length () <= length ){
Result. add (s );
}
}
Return result;
}
Public static void main (String [] args ){
List names = new ArrayList ();
Names. add ("Ted"); names. add ("Fred ");
Names. add ("Jed"); names. add ("Ned ");
System. out. println (names );
Erase e = new Erase ();
List shortNames = e. filterLongerThan (names, 3 );
System. out. println (shortNames. size ());
For (int I = 0; I <shortNames. size (); I ++ ){
String s = (String) shortNames. get (I );
System. out. println (s );
}
}
}
To achieve the same effect, use the groovy script that is also running in the java virtual machine to write it again:
Names = ["Ted", "Fred", "Jed", "Ned"]
Println names
ShortNames = names. findAll {it. size () <= 3}
Println shortNames. size ()
ShortNames. each {println it}
 
Don't mention performance to me, just as java developers told me when I used c ++ to write programs: the memory is so cheap now, just buy more.
Far away, it would be nice to combine the unit test in J2EE with groovy.

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.