This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.junit; | |
| public class MyMath { | |
| int sum(int[] numbers) { | |
| int sum =0; | |
| for(int i:numbers) { | |
| sum+=i; | |
| } | |
| return sum; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.junit; | |
| import static org.junit.Assert.*; | |
| import org.junit.Test; | |
| public class MyMathTest { | |
| @Test | |
| public void test() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.junit; | |
| import static org.junit.Assert.*; | |
| import org.junit.Test; | |
| public class MyMathTest { | |
| @Test | |
| public void test() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.junit; | |
| import static org.junit.Assert.*; | |
| import org.junit.Test; | |
| public class MyMathTest { | |
| //第一步 先建立MyMath實例myMath | |
| MyMath myMath =new MyMath(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.junit; | |
| import static org.junit.Assert.*; | |
| import org.junit.Test; | |
| public class AssertTest { | |
| @Test | |
| public void test() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.junit; | |
| import static org.junit.Assert.*; | |
| import org.junit.Before; | |
| import org.junit.Test; | |
| public class MyMathTest { | |
| //第一步 先建立MyMath實例myMath |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.junit; | |
| import static org.junit.Assert.assertEquals; | |
| import org.junit.After; | |
| import org.junit.AfterClass; | |
| import org.junit.Before; | |
| import org.junit.BeforeClass; | |
| import org.junit.Test; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.mockito.mockito; | |
| public class SomeBusinessImpl { | |
| private DataService dataService; | |
| //為了測試 需建立建構子(因為測試過程 spring不會協助注入dataService) | |
| public SomeBusinessImpl(DataService dataService) { | |
| super(); | |
| this.dataService = dataService; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.mockito.mockito; | |
| public interface DataService{ | |
| int [] retrieveAllData(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.mockito.mockito; | |
| import static org.junit.Assert.*; | |
| import org.junit.Test; | |
| public class SomeBusinessTest { | |
| @Test | |
| public void testFindTheGreatestFromAllData() { |