Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Day 1 - Testing

offz
April 19, 2017

Day 1 - Testing

Automate software testing with Java for beginner.

offz

April 19, 2017
Tweet

More Decks by offz

Other Decks in Programming

Transcript

  1. Now

  2. วิธีการ Test class Calculator { public int plus(int a, int

    b) { return a + b; } } class CalculatorTests { public boolean testPlus() { Calculator calculator = new Calculator(); int result = calculator.plus(1, 2); return result == 3; } }
  3. วิธีการ Test class TestMain { public static void main(String[] args)

    { CalculatorTests suit = new CalculatorTests(); if (suit.testPlus) { System.out.println("You survive!"); } else { System.out.println("You died!"); System.exit(-1); } } }
  4. JUnit Test class CalculatorTests { Calculator calculator; @Before public void

    setup() { calculator = new Calculator(); } @Test public void test1Plus2Equals3() { int result = calculator.plus(1, 2); assertEquals(result, 3) } @After public void tearDown() { calculator = null; } }
  5. exercise 1 1. clone project FizzBuzz 2. อ่าน README และทำความเข้าใจ

    3. เปิด project ใน Eclipse แล้วสร้าง test case ใหม่ๆ 4. ทดลองรัน Test ใน Eclipse ด้วย JUnit
  6. exercise 2 1. clone project chidchat 2. ลองรัน Server และ

    Client เล่น 3. ลองนำ Client ไปต่อกับ server • host: 128.199.193.120 • port: 5000
  7. exercise 2.1 1. ให้เลือก emoticon 1 ตัวจาก • https://www.emojicopy.com/ 2.

    สร้าง issue emoticon <emo-name> 3. ทำให้ server สามารถรับ keyword 
 แล้วแสดงเป็น emoticon ได้ • เช่น :sob: แสดงเป็น เขียน 
 Test ด้วย!!