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

UptoLike

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

ɋɬɟɩɚɧɰɨɜ ȼ.Ⱥ. ɉɪɚɤɬɢɱɟɫɤɚɹ ɪɚɛɨɬɚ ɜ Eclipse 3.2
51
3. ɓɟɥɤɧɢɬɟ ɧɚ Finish ɞɥɹ ɫɨɡɞɚɧɢɹ ɤɥɚɫɫɚ ɬɟɫɬɚ.
Ⱦɨɛɚɜɶɬɟ ɦɟɬɨɞ ɬɟɫɬɢɪɨɜɚɧɢɹ ɜ ɤɥɚɫɫ
TestFailure. Ȼɵɫɬɪɵɣ ɫɩɨɫɨɛ ɫɨɡɞɚɧɢɹ
ɬɟɫɬɨɜɨɝɨ ɦɟɬɨɞɚɩɪɢ ɩɨɦɨɳɢ ɲɚɛɥɨɧɚ
test. ɑɬɨɛɵ ɷɬɨ ɫɞɟɥɚɬɶ, ɜɜɟɞɢɬɟ
test ɢ Ctrl+Space ɞɥɹ ɚɤɬɢɜɢɡɚɰɢɢ ɤɨɧɬɟɧɬɧɨɣ ɩɨɦɨɳɢ ɢ ɜɵɛɟɪɢɬɟ ɲɚɛɥɨɧ
test. ɂɡɦɟɧɢɬɟ ɢɦɹ ɫɨɡɞɚɜɚɟɦɨɝɨ ɦɟɬɨɞɚ ɧɚ testFailure ɢ ɜɵɡɨɜɢɬɟ ɦɟɬɨɞ
fail(). Ɍɚɤɠɟ ɢɡɦɟɧɢɬɟ ɦɨɞɢɮɢɤɚɬɨɪ ɜɢɞɢɦɨɫɬɢ, ɱɬɨɛɵ ɷɬɨɬ ɦɟɬɨɞ
ɬɟɫɬɢɪɨɜɚɧɢɹ ɛɵɥ ɨɬɤɪɵɬɵɦ.
public void testFailure(){
fail();
}
8.1. ȼɵɩɨɥɧɟɧɢɟ ɬɟɫɬɨɜ
ɑɬɨɛɵ ɡɚɩɭɫɬɢɬɶ
TestFailure, ɚɤɬɢɜɢɡɢɪɭɣɬɟ ɜ ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ ɢ
ɜɵɛɟɪɢɬɟ Run as > JUnit Test. Ɇɨɠɧɨ ɩɪɨɢɧɫɩɟɤɬɢɪɨɜɚɬɶ ɪɟɡɭɥɶɬɚɬɵ
ɬɟɫɬɚ ɜ ɩɪɟɞɫɬɚɜɥɟɧɢɢ
JUnit. ɗɬɨ ɩɪɟɞɫɬɚɜɥɟɧɢɟ ɩɨɤɚɡɵɜɚɟɬ ɯɨɞ
ɜɵɩɨɥɧɟɧɢɹ ɢ ɫɨɫɬɨɹɧɢɟ ɬɟɫɬɚ:
                                        ɋɬɟɩɚɧɰɨɜ ȼ.Ⱥ. ɉɪɚɤɬɢɱɟɫɤɚɹ ɪɚɛɨɬɚ ɜ Eclipse 3.2




     3. ɓɟɥɤɧɢɬɟ ɧɚ Finish ɞɥɹ ɫɨɡɞɚɧɢɹ ɤɥɚɫɫɚ ɬɟɫɬɚ.
Ⱦɨɛɚɜɶɬɟ ɦɟɬɨɞ ɬɟɫɬɢɪɨɜɚɧɢɹ ɜ ɤɥɚɫɫ TestFailure. Ȼɵɫɬɪɵɣ ɫɩɨɫɨɛ ɫɨɡɞɚɧɢɹ
ɬɟɫɬɨɜɨɝɨ ɦɟɬɨɞɚ – ɩɪɢ ɩɨɦɨɳɢ ɲɚɛɥɨɧɚ test. ɑɬɨɛɵ ɷɬɨ ɫɞɟɥɚɬɶ, ɜɜɟɞɢɬɟ
test ɢ Ctrl+Space ɞɥɹ ɚɤɬɢɜɢɡɚɰɢɢ ɤɨɧɬɟɧɬɧɨɣ ɩɨɦɨɳɢ ɢ ɜɵɛɟɪɢɬɟ ɲɚɛɥɨɧ
test. ɂɡɦɟɧɢɬɟ ɢɦɹ ɫɨɡɞɚɜɚɟɦɨɝɨ ɦɟɬɨɞɚ ɧɚ testFailure ɢ ɜɵɡɨɜɢɬɟ ɦɟɬɨɞ
fail(). Ɍɚɤɠɟ ɢɡɦɟɧɢɬɟ ɦɨɞɢɮɢɤɚɬɨɪ ɜɢɞɢɦɨɫɬɢ, ɱɬɨɛɵ ɷɬɨɬ ɦɟɬɨɞ
ɬɟɫɬɢɪɨɜɚɧɢɹ ɛɵɥ ɨɬɤɪɵɬɵɦ.
   public void testFailure(){
     fail();
   }
   8.1. ȼɵɩɨɥɧɟɧɢɟ ɬɟɫɬɨɜ
ɑɬɨɛɵ ɡɚɩɭɫɬɢɬɶ TestFailure, ɚɤɬɢɜɢɡɢɪɭɣɬɟ ɜ ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ ɢ
ɜɵɛɟɪɢɬɟ Run as > JUnit Test. Ɇɨɠɧɨ ɩɪɨɢɧɫɩɟɤɬɢɪɨɜɚɬɶ ɪɟɡɭɥɶɬɚɬɵ
ɬɟɫɬɚ ɜ ɩɪɟɞɫɬɚɜɥɟɧɢɢ JUnit. ɗɬɨ ɩɪɟɞɫɬɚɜɥɟɧɢɟ ɩɨɤɚɡɵɜɚɟɬ ɯɨɞ
ɜɵɩɨɥɧɟɧɢɹ ɢ ɫɨɫɬɨɹɧɢɟ ɬɟɫɬɚ:




                                   51