zoukankan      html  css  js  c++  java
  • 2019软件工程第二次作业---付志峰

    (一)、建立需测试的项目

     1、新建项目

      

     2、正常书写.h和.cpp文件

    #pragma once
    class jiafa
    {
    public:
    	int add(int x, int y);
    };
    
    #include "标头.h"
    #include "iostream"
    using namespace std;
    int jiafa::add(int x, int y)
    {
    	return x + y;
    }
    
    int main()
    {
    	return 0;
    }
    

      
      

    (二)、新单元测试

     1、右击解决方案->添加->新建项目

       Visual C++->测试->本机单元测试项目

      

    (三)、添加被测项目的引用

     UnitTest1(个人单元测试项目名称,下同)->右击引用->添加引用->勾选被测试项目

      

    (四)、编写测试代码

      修改unittest1.cpp

    #include "stdafx.h"
    #include "CppUnitTest.h"
    #include"..fzf标头.h"
    
    using namespace Microsoft::VisualStudio::CppUnitTestFramework;
    
    namespace UnitTest1
    {		
    	TEST_CLASS(UnitTest1)
    	{
    	public:
    		
    		TEST_METHOD(TestMethod1)
    		{
    			// TODO: 在此输入测试代码
    			jiafa a;
    			int x = 1, y = 2, result = 3;
    			int real = a.add(x, y);
    			Assert::AreEqual(real, result);
    		}
    
    	};
    }
    

    (五)、运行测试

      测试->运行->所有测试

      
      

  • 相关阅读:
    Codeforces 985G. Team Players
    关于Hall定理的学习
    bzoj 4561: [JLoi2016]圆的异或并
    UOJ #188. 【UR #13】Sanrd
    LOJ #6053. 简单的函数
    Codeforces F. Cowmpany Cowmpensation
    POJ 3710:Matrix Power Series
    codeforces533E
    luogu2885
    codeforces722E
  • 原文地址:https://www.cnblogs.com/fuzhifeng/p/10698574.html
Copyright © 2011-2022 走看看