Advertisement
Guest User

Untitled

a guest
Sep 24th, 2011
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. CodeProExperiences:
  2.  
  3. When I first installed CodePro in my Eclipse Helios (JEE) it crashed every time I did a right click. Eclipse is fragile when you have many components installed, for example the JBoss Tools and Seam, which aren't really 100% stable. My colleague was especially interested in Remote Interface tests but abandonded this plan altogether.
  4.  
  5. Ok, so my first impression was that it was yet another buggy Eclipse plugin and that it sucked but I decided to give it another try, this time with a pure and clean Eclipse installation.
  6.  
  7. Well, it worked. The Unit Test generation is nothing impressive, it basically just creates skeletons and you have a fancy GUI to add methods, provide arguments and specify assertions. Sadly, you cannot specify assertions for every test. As I stated already, the tests can be used as skeletons but they aren't really impressive and not to my liking. However, they generate a really high code coverage (90% in my testcases).
  8.  
  9. But in my opinion, there's so much manual work involved that it makes little difference if you generate the tests or if you write them completely by yourself. Sometimes the generated tests are ridiculous, I guess I had too high expectations when I heard that the great Google had created a tool for such a thing.
  10.  
  11. So, the test generation couldn't statisfy my high expectations. They can be a help here and there to achieve a really high coverage but personally I wouldn't use it, because when you're finished with the test there's next to nothing left from the skeleton that Code Pro generated.
  12. That doesn't mean CodePro is completely useless, it does have some nice features. The metrics are nice for a quick overview and can be fed your own rules. I like such things. And the code coverage visualization is nice to have, too. I'll keep it as a plugin.
  13.  
  14. At last, I should point out that this is only my subjective opinion. Maybe other people like the test generation or have a better use for it.
  15.  
  16.  
  17. Below you'll find some examples of the generated tests:
  18.  
  19. @Test
  20. public void testSwap_1()
  21. throws Exception {
  22. int[] array = new int[] {0};
  23. int idx1 = 1;
  24. int idx2 = 1;
  25.  
  26. Sort.swap(array, idx1, idx2);
  27.  
  28. // add additional test code here
  29. // An unexpected exception was thrown in user code while executing this test:
  30. // java.lang.ArrayIndexOutOfBoundsException: 1
  31. // at Sort.swap(Sort.java:26)
  32. }
  33.  
  34.  
  35. //WHY DID IT GENERATE THE SAME TEST TWICE? It generated 16 tests for quicksort in total.
  36.  
  37. @Test
  38. public void testQsort_15()
  39. throws Exception {
  40. int[] array = new int[] {};
  41. int le = 1;
  42. int ri = 1;
  43.  
  44. Sort.qsort(array, le, ri);
  45.  
  46. // add additional test code here
  47. }
  48.  
  49. /**
  50. * Run the void qsort(int[],int,int) method test.
  51. *
  52. * @throws Exception
  53. *
  54. * @generatedBy CodePro at 24.09.11 17:33
  55. */
  56. @Test
  57. public void testQsort_16()
  58. throws Exception {
  59. int[] array = new int[] {};
  60. int le = 1;
  61. int ri = 1;
  62.  
  63. Sort.qsort(array, le, ri);
  64.  
  65. // add additional test code here
  66. }
  67.  
  68.  
  69. //useless
  70.  
  71. @Test
  72. public void testValueAsString_2()
  73. throws Exception {
  74. TestsWithStrings fixture = new TestsWithStrings();
  75. Object object = new Object();
  76.  
  77. String result = fixture.valueAsString(object);
  78.  
  79. // add additional test code here
  80. assertEquals("java.lang.Object@52a56fa5", result);
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement