#29 Added test

開啟中
TSRogers28 請求將 2 次程式碼提交從 TSRogers28/ZCW-SumOfInput-BlueJ:master 合併至 master
共有 8 個文件被更改,包括 90 次插入21 次删除
  1. 0
    9
      Main.java
  2. 二進制
      SumOfInput.class
  3. 7
    0
      SumOfInput.ctxt
  4. 22
    0
      SumOfInput.java
  5. 二進制
      SumOfInputTest.class
  6. 6
    0
      SumOfInputTest.ctxt
  7. 32
    0
      SumOfInputTest.java
  8. 23
    12
      package.bluej

+ 0
- 9
Main.java 查看文件

@@ -1,9 +0,0 @@
1
-/**
2
- * Created by iyasuwatts on 10/17/17.
3
- */
4
-public class Main {
5
-
6
-    public static void main(String[] args){
7
-
8
-    }
9
-}

二進制
SumOfInput.class 查看文件


+ 7
- 0
SumOfInput.ctxt 查看文件

@@ -0,0 +1,7 @@
1
+#BlueJ class context
2
+comment0.target=SumOfInput
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5
+comment2.params=input
6
+comment2.target=int\ getSum(int)
7
+numComments=3

+ 22
- 0
SumOfInput.java 查看文件

@@ -0,0 +1,22 @@
1
+/**
2
+ * Created by iyasuwatts on 10/17/17.
3
+ */
4
+import java.util.*;
5
+public class SumOfInput {
6
+
7
+    public static void main(String[] args){
8
+
9
+    }
10
+    Scanner scan = new Scanner(System.in);
11
+    int input = scan.nextInt();
12
+    public int getSum(int input){
13
+        System.out.println("Enter a number");     
14
+        int sum = 0;
15
+        for(int x = 0; x <= input; x++){
16
+            sum += x;
17
+        }
18
+        System.out.println(sum);
19
+        return sum;
20
+    }
21
+}
22
+

二進制
SumOfInputTest.class 查看文件


+ 6
- 0
SumOfInputTest.ctxt 查看文件

@@ -0,0 +1,6 @@
1
+#BlueJ class context
2
+comment0.target=SumOfInputTest
3
+comment0.text=\n\ The\ test\ class\ SumOfInputTest.\n\n\ @author\ \ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=
5
+comment1.target=void\ testSumOfInput()
6
+numComments=2

+ 32
- 0
SumOfInputTest.java 查看文件

@@ -0,0 +1,32 @@
1
+
2
+
3
+import org.junit.Assert;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+/**
9
+ * The test class SumOfInputTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class SumOfInputTest
15
+{ SumOfInput testSum = new SumOfInput();
16
+    @Test
17
+    public void testSumOfInput()
18
+    {
19
+    
20
+    {
21
+        // : Given
22
+        int passingTestValue = 10;
23
+        int expected = 55;
24
+
25
+        // : When
26
+        int actual = testSum.getSum(10);
27
+
28
+        // : Then
29
+        Assert.assertEquals(expected, actual);
30
+    }
31
+    }
32
+}

+ 23
- 12
package.bluej 查看文件

@@ -1,20 +1,23 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=0
3
-editor.fx.0.width=0
4
-editor.fx.0.x=0
5
-editor.fx.0.y=0
2
+dependency1.from=SumOfInputTest
3
+dependency1.to=SumOfInput
4
+dependency1.type=UsesDependency
5
+editor.fx.0.height=722
6
+editor.fx.0.width=800
7
+editor.fx.0.x=26
8
+editor.fx.0.y=23
6 9
 objectbench.height=164
7 10
 objectbench.width=776
8 11
 package.divider.horizontal=0.6
9 12
 package.divider.vertical=0.6845018450184502
10 13
 package.editor.height=364
11 14
 package.editor.width=674
12
-package.editor.x=-816
13
-package.editor.y=445
15
+package.editor.x=0
16
+package.editor.y=79
14 17
 package.frame.height=600
15 18
 package.frame.width=800
16
-package.numDependencies=0
17
-package.numTargets=1
19
+package.numDependencies=1
20
+package.numTargets=2
18 21
 package.showExtends=true
19 22
 package.showUses=true
20 23
 project.charset=UTF-8
@@ -23,10 +26,18 @@ readme.name=@README
23 26
 readme.width=47
24 27
 readme.x=10
25 28
 readme.y=10
29
+target1.association=SumOfInputTest
26 30
 target1.height=50
27
-target1.name=Main
31
+target1.name=SumOfInput
28 32
 target1.showInterface=false
29 33
 target1.type=ClassTarget
30
-target1.width=80
31
-target1.x=70
32
-target1.y=10
34
+target1.width=100
35
+target1.x=140
36
+target1.y=80
37
+target2.height=50
38
+target2.name=SumOfInputTest
39
+target2.showInterface=false
40
+target2.type=UnitTestTargetJunit4
41
+target2.width=100
42
+target2.x=170
43
+target2.y=50