zoukankan      html  css  js  c++  java
  • 【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:

  • 相关阅读:
    IE7下元素的 'paddingtop' 遇到 'clear' 特性在某些情况下复制到 'paddingbottom'
    Foundation HTML5 Canvas中的2处错误
    近期学习技术安排
    2011年工作总结和展望(上篇)
    详解ObjectiveC消息传递机制
    ObjectiveC 2.0的运行时编程消息转发
    c# Pdf 转换图片
    c语言指针用法难点
    C# web实现word 转Html、office转Html、pdf转图片 在线预览文件
    ObjectiveC中什么是类
  • 原文地址:https://www.cnblogs.com/cassiecassie/p/4460743.html
Copyright © 2011-2022 走看看