Skip to content

Instantly share code, notes, and snippets.

@JavaNoobPig
JavaNoobPig / IntroductionSpring20_1.java
Created February 23, 2019 08:03
IntroductionSpring20_1
package com.pig.junit;
public class MyMath {
int sum(int[] numbers) {
int sum =0;
for(int i:numbers) {
sum+=i;
}
return sum;
@JavaNoobPig
JavaNoobPig / IntroductionSpring20_2.java
Created February 23, 2019 08:14
IntroductionSpring20_2
package com.pig.junit;
import static org.junit.Assert.*;
import org.junit.Test;
public class MyMathTest {
@Test
public void test() {
@JavaNoobPig
JavaNoobPig / IntroductionSpring20_3.java
Created February 23, 2019 08:17
IntroductionSpring20_3
package com.pig.junit;
import static org.junit.Assert.*;
import org.junit.Test;
public class MyMathTest {
@Test
public void test() {
@JavaNoobPig
JavaNoobPig / IntroductionSpring20_4.java
Created February 23, 2019 08:29
IntroductionSpring20_4
package com.pig.junit;
import static org.junit.Assert.*;
import org.junit.Test;
public class MyMathTest {
//第一步 先建立MyMath實例myMath
MyMath myMath =new MyMath();
@JavaNoobPig
JavaNoobPig / IntroductionSpring20_5.java
Created February 23, 2019 08:40
IntroductionSpring20_5
package com.pig.junit;
import static org.junit.Assert.*;
import org.junit.Test;
public class AssertTest {
@Test
public void test() {
@JavaNoobPig
JavaNoobPig / IntroductionSpring21_1.java
Created February 23, 2019 08:48
IntroductionSpring21_1
package com.pig.junit;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
public class MyMathTest {
//第一步 先建立MyMath實例myMath
@JavaNoobPig
JavaNoobPig / IntroductionSpring21_2.java
Last active February 23, 2019 08:58
IntroductionSpring21_2
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;
@JavaNoobPig
JavaNoobPig / IntroductionSpring22_1.java
Last active February 25, 2019 04:12
IntroductionSpring22_1
package com.pig.mockito.mockito;
public class SomeBusinessImpl {
private DataService dataService;
//為了測試 需建立建構子(因為測試過程 spring不會協助注入dataService)
public SomeBusinessImpl(DataService dataService) {
super();
this.dataService = dataService;
}
@JavaNoobPig
JavaNoobPig / IntroductionSpring22_2.java
Created February 25, 2019 03:42
IntroductionSpring22_2
package com.pig.mockito.mockito;
public interface DataService{
int [] retrieveAllData();
}
@JavaNoobPig
JavaNoobPig / IntroductionSpring22_3.java
Created February 25, 2019 03:54
IntroductionSpring22_3
package com.pig.mockito.mockito;
import static org.junit.Assert.*;
import org.junit.Test;
public class SomeBusinessTest {
@Test
public void testFindTheGreatestFromAllData() {