Практическая работа в ECLIPSE 3.2. Степанцов В.А. - 53 стр.

UptoLike

Составители: 

ɋɬɟɩɚɧɰɨɜ ȼ.Ⱥ. ɉɪɚɤɬɢɱɟɫɤɚɹ ɪɚɛɨɬɚ ɜ Eclipse 3.2
53
ɧɚɯɨɞɢɬ ɜɫɟ ɬɟɫɬɵ ɜɧɭɬɪɢ ɩɪɨɟɤɬɚ, ɢɫɯɨɞɧɨɣ ɩɚɩɤɢ ɢɥɢ ɩɚɤɟɬɚ ɢ
ɜɵɩɨɥɧɹɟɬ ɢɯ.
2. ȼɵɩɨɥɧɹɬɶ ɟɞɢɧɫɬɜɟɧɧɵɣ ɦɟɬɨɞ ɬɟɫɬɚ. Ⱦɥɹ ɷɬɨɝɨ ɜɵɛɟɪɢɬɟ ɦɟɬɨɞ
ɬɟɫɬɚ ɜ Outline ɢɥɢ Package Explorer ɢ ɩɪɢ ɩɨɦɨɳɢ Run as > JUnit
Test ɜɵɛɪɚɧɧɵɣ ɦɟɬɨɞ ɛɭɞɟɬ ɜɵɩɨɥɧɟɧ.
3. ȼɵɩɨɥɧɹɬɶ ɟɞɢɧɫɬɜɟɧɧɵɣ ɬɟɫɬ. Ⱦɥɹ ɷɬɨɝɨ ɜɵɛɟɪɢɬɟ ɬɟɫɬ ɜ
ɩɪɟɞɫɬɚɜɥɟɧɢɢ JUnit ɢ ɜɵɩɨɥɧɢɬɟ Rerun ɢɡ ɤɨɧɬɟɤɫɬɧɨɝɨ ɦɟɧɸ.
8.2. ɇɚɫɬɪɨɣɤɚ ɤɨɧɮɢɝɭɪɚɰɢɢ ɬɟɫɬɚ
ȿɫɥɢ ɧɟɨɛɯɨɞɢɦɨ ɩɟɪɟɞɚɬɶ ɩɚɪɚɦɟɬɪɵ ɢɥɢ ɧɚɫɬɪɨɢɬɶ ɭɫɬɚɧɨɜɤɢ ɞɥɹ
ɜɵɩɨɥɧɟɧɢɹ ɬɟɫɬɚ, ɨɬɤɪɨɣɬɟ ɞɢɚɥɨɝ Launch Configuration. ȼɵɛɟɪɢɬɟ Run...
ɜ ɜɵɩɚɞɚɸɳɟɦ ɦɟɧɸ Run ɜ ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ:
ȼ ɷɬɨɦ ɞɢɚɥɨɝɟ ɦɨɠɧɨ ɡɚɞɚɬɶ ɜɵɩɨɥɧɹɟɦɵɣ ɬɟɫɬ, ɟɝɨ ɚɪɝɭɦɟɧɬɵ, classpath
ɦɨɦɟɧɬɚ ɜɵɩɨɥɧɟɧɢɹ ɢ ɫɪɟɞɭ Java ɦɨɦɟɧɬɚ ɜɵɩɨɥɧɟɧɢɹ.
8.3. Ɉɬɥɚɞɤɚ ɨɲɢɛɨɤ ɬɟɫɬɚ
ȼ ɫɥɭɱɚɟ ɨɲɢɛɤɢ ɬɟɫɬɚ ɦɨɠɧɨ ɫɥɟɞɨɜɚɬɶ ɬɚɤɢɦ ɲɚɝɚɦ ɞɥɹ ɟɝɨ ɨɬɥɚɞɤɢ:
1. ɓɟɥɤɧɢɬɟ ɞɜɚɠɞɵ ɧɚ ɷɥɟɦɟɧɬɟ ɨɲɢɛɤɢ ɜ ɬɪɚɫɫɟ ɫɬɟɤɚ ɜ
ɩɪɟɞɫɬɚɜɥɟɧɢɢ
JUnit, ɱɬɨɛɵ ɨɬɤɪɵɬɶ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɣ ɮɚɣɥ ɜ
ɪɟɞɚɤɬɨɪɟ.
2. ɍɫɬɚɧɨɜɢɬɟ ɬɨɱɤɭ ɨɫɬɚɧɨɜɚ ɧɚ ɧɚɱɚɥɨ ɦɟɬɨɞɚ ɬɟɫɬɚ.
3. ȼɵɛɟɪɢɬɟ ɜɚɪɢɚɧɬ ɬɟɫɬɚ ɢ ɜɵɩɨɥɧɢɬɟ Debug As > JUnit Test ɢɡ
ɜɵɩɚɞɚɸɳɟɝɨ Debug.
Ʉɨɧɮɢɝɭɪɚɰɢɹ ɡɚɩɭɫɤɚ
JUnit ɢɦɟɟɬ ɨɩɰɢɸ ɨɫɬɚɜɢɬɶ ɜ ɠɢɜɵɯ. ȿɫɥɢ ɜɚɲɚ
Java VM ɩɨɞɞɟɪɠɢɜɚɟɬ ɝɨɪɹɱɭɸ ɡɚɦɟɧɭ ɤɨɞɚ ɦɨɠɧɨ ɢɫɩɪɚɜɢɬɶ ɤɨɞ ɢ
                                       ɋɬɟɩɚɧɰɨɜ ȼ.Ⱥ. ɉɪɚɤɬɢɱɟɫɤɚɹ ɪɚɛɨɬɚ ɜ Eclipse 3.2

     ɧɚɯɨɞɢɬ ɜɫɟ ɬɟɫɬɵ ɜɧɭɬɪɢ ɩɪɨɟɤɬɚ, ɢɫɯɨɞɧɨɣ ɩɚɩɤɢ ɢɥɢ ɩɚɤɟɬɚ ɢ
     ɜɵɩɨɥɧɹɟɬ ɢɯ.
  2. ȼɵɩɨɥɧɹɬɶ ɟɞɢɧɫɬɜɟɧɧɵɣ ɦɟɬɨɞ ɬɟɫɬɚ. Ⱦɥɹ ɷɬɨɝɨ ɜɵɛɟɪɢɬɟ ɦɟɬɨɞ
     ɬɟɫɬɚ ɜ Outline ɢɥɢ Package Explorer ɢ ɩɪɢ ɩɨɦɨɳɢ Run as > JUnit
     Test ɜɵɛɪɚɧɧɵɣ ɦɟɬɨɞ ɛɭɞɟɬ ɜɵɩɨɥɧɟɧ.
  3. ȼɵɩɨɥɧɹɬɶ ɟɞɢɧɫɬɜɟɧɧɵɣ ɬɟɫɬ. Ⱦɥɹ ɷɬɨɝɨ ɜɵɛɟɪɢɬɟ ɬɟɫɬ ɜ
     ɩɪɟɞɫɬɚɜɥɟɧɢɢ JUnit ɢ ɜɵɩɨɥɧɢɬɟ Rerun ɢɡ ɤɨɧɬɟɤɫɬɧɨɝɨ ɦɟɧɸ.
   8.2. ɇɚɫɬɪɨɣɤɚ ɤɨɧɮɢɝɭɪɚɰɢɢ ɬɟɫɬɚ
ȿɫɥɢ ɧɟɨɛɯɨɞɢɦɨ ɩɟɪɟɞɚɬɶ ɩɚɪɚɦɟɬɪɵ ɢɥɢ ɧɚɫɬɪɨɢɬɶ ɭɫɬɚɧɨɜɤɢ ɞɥɹ
ɜɵɩɨɥɧɟɧɢɹ ɬɟɫɬɚ, ɨɬɤɪɨɣɬɟ ɞɢɚɥɨɝ Launch Configuration. ȼɵɛɟɪɢɬɟ Run...
ɜ ɜɵɩɚɞɚɸɳɟɦ ɦɟɧɸ Run ɜ ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ:




ȼ ɷɬɨɦ ɞɢɚɥɨɝɟ ɦɨɠɧɨ ɡɚɞɚɬɶ ɜɵɩɨɥɧɹɟɦɵɣ ɬɟɫɬ, ɟɝɨ ɚɪɝɭɦɟɧɬɵ, classpath
ɦɨɦɟɧɬɚ ɜɵɩɨɥɧɟɧɢɹ ɢ ɫɪɟɞɭ Java ɦɨɦɟɧɬɚ ɜɵɩɨɥɧɟɧɢɹ.
   8.3. Ɉɬɥɚɞɤɚ ɨɲɢɛɨɤ ɬɟɫɬɚ
ȼ ɫɥɭɱɚɟ ɨɲɢɛɤɢ ɬɟɫɬɚ ɦɨɠɧɨ ɫɥɟɞɨɜɚɬɶ ɬɚɤɢɦ ɲɚɝɚɦ ɞɥɹ ɟɝɨ ɨɬɥɚɞɤɢ:
   1. ɓɟɥɤɧɢɬɟ ɞɜɚɠɞɵ ɧɚ ɷɥɟɦɟɧɬɟ ɨɲɢɛɤɢ ɜ ɬɪɚɫɫɟ ɫɬɟɤɚ ɜ
      ɩɪɟɞɫɬɚɜɥɟɧɢɢ JUnit, ɱɬɨɛɵ ɨɬɤɪɵɬɶ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɣ ɮɚɣɥ ɜ
      ɪɟɞɚɤɬɨɪɟ.
   2. ɍɫɬɚɧɨɜɢɬɟ ɬɨɱɤɭ ɨɫɬɚɧɨɜɚ ɧɚ ɧɚɱɚɥɨ ɦɟɬɨɞɚ ɬɟɫɬɚ.
   3. ȼɵɛɟɪɢɬɟ ɜɚɪɢɚɧɬ ɬɟɫɬɚ ɢ ɜɵɩɨɥɧɢɬɟ Debug As > JUnit Test ɢɡ
      ɜɵɩɚɞɚɸɳɟɝɨ Debug.
Ʉɨɧɮɢɝɭɪɚɰɢɹ ɡɚɩɭɫɤɚ JUnit ɢɦɟɟɬ ɨɩɰɢɸ ɨɫɬɚɜɢɬɶ ɜ ɠɢɜɵɯ. ȿɫɥɢ ɜɚɲɚ
Java VM ɩɨɞɞɟɪɠɢɜɚɟɬ ɝɨɪɹɱɭɸ ɡɚɦɟɧɭ ɤɨɞɚ ɦɨɠɧɨ ɢɫɩɪɚɜɢɬɶ ɤɨɞ ɢ

                                  53