Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CALC.CPP:
- ---------
- #include "Calc.h"
- int Calc::sum(int a, int b){
- return a+b;
- }
- int Calc::mul(int a, int b){
- return a*b;
- }
- CALCTEST.CPP:
- -------------
- #include "stdafx.h"
- #include "Calc.h"
- #include <iostream>
- using namespace std;
- using namespace System;
- using namespace System::Text;
- using namespace System::Collections::Generic;
- using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
- namespace CalcTest
- {
- [TestClass]
- public ref class CalcTest
- {
- private:
- TestContext^ testContextInstance;
- public:
- #pragma region Additional test attributes
- #pragma endregion
- [TestMethod]
- void TestMethod1()
- {
- Calc c;
- int r1 = c.sum(1,2);
- int r2 = c.sum(2,3);
- if( r1==3 && r2==4 ) {
- std::cout<<"Correct!";
- }
- Assert::AreEqual<int>(4, c.sum(1, 2));
- }
- [TestMethod]
- void TestMethod2()
- {
- Calc c;
- Assert::AreEqual<int>(3, c.sum(1, 2));
- }
- [TestMethod]
- void TestMethod3()
- {
- Calc c;
- Assert::AreEqual<int>(2, c.mul(1, 2));
- }
- };
- }
- BATCH SCRIPT:
- -------------
- SET projdir=C:\Users\abudhaks\Documents\Visual Studio 2010\Projects\CalcProject
- SET chrome=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
- REM Triggering OpenCover
- "C:\Users\abudhaks\AppData\Local\Apps\OpenCover\OpenCover.Console.exe"^
- -register:user^
- -target:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"^
- -targetargs:"/noresults /noisolation /testcontainer:\"%projdir%\Debug\CalcTest.dll\""^
- -mergebyhash^
- -showunvisited^
- -output:"%projdir%\CoverageReport.xml"
- REM Creating a report directory
- MKDIR "%projdir%\report"
- REM Triggering ReportGenerator
- "C:\Users\abudhaks\Downloads\ReportGenerator_1.9.1.0\bin\ReportGenerator.exe"^
- -reports:"%projdir%\CoverageReport.xml"^
- -targetdir:"%projdir%\report"^
- -reporttypes:Html,HtmlSummary^
- -sourcedirs:"%projdir%\CalcProject"
- REM Opening the report
- "%chrome%" "%projdir%\report\index.htm"
- pause
Advertisement
Add Comment
Please, Sign In to add comment