【Software Project Management】Quizs

Task1:Develop the project “HelloWorld”
    -A .java program: Just print out “Hello” + your name;
    -A test case using Junit to verify whether the program works well.

a:A .java program: Just print out “Hello” + your name:

Code:

package spm;

public class Hello {
    public String cassie(){
        return "Hello Cassie";
    }
    public static void main(String[] args) {
        Hello cassie = new Hello();
        System.out.println(cassie.cassie());
        return;
    }
}

Screenshot:

b:A test case using Junit to verify whether the program works well:

Click the right button on the package"spm"—>build path—>add libraries—>junit

Then create junit test case

Code:

package spm;

import static org.junit.Assert.*;
import junit.framework.TestCase;

import org.junit.Test;

public class HelloTest extends TestCase{
    public void test(){
        Hello testHello = new Hello();
        assertEquals("Hello Cassie",testHello.cassie());
    }
}
Then run it

Screenshot:

 

Task2:Install Maven and Build the “HelloWorld” Project
    -Create the directories as “Convention Over Configuration".
    -Use “compile, test, package” to  build the project.
a:Create the directories as “Convention Over Configuration":

I install Maven and set environmental variables by looking into relevant passages online. After that I check whether Maven is installed in my laptop.

Screenshot:

b:Use “compile, test, package” to  build the project:

File—>New—>Other—>Maven—>Maven Project

In the App.java:

code:

package Sap.SapCassie;

//import spm.Hello;

/**
 * Hello world!
 *
 */
public class App
{
    public String cassie(){
        return "Hello Cassie";
    }
    public static void main(String[] args) {
        App cassie = new App();
        System.out.println(cassie.cassie());
        return;
    }
    
}

In the AppTest.java:

code:

package Sap.SapCassie;

//import spm.Hello;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * Unit test for simple App.
 */
public class AppTest
    extends TestCase
{
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public AppTest( String testName )
    {
        super( testName );
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( AppTest.class );
    }

    /**
     * Rigourous Test :-)
     */
    public void testApp()
    {
        assertTrue( true );
    }
    public void test(){
        App testHello = new App();
        assertEquals("Hello Cassie",testHello.cassie());
    }
}

Run the project:

Screenshot:

 

转载于:https://www.cnblogs.com/cassiecassie/p/4460743.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值