Guest User

Untitled

a guest
Apr 30th, 2014
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CALC.CPP:
  2. ---------
  3.  
  4. #include "Calc.h"
  5. int Calc::sum(int a, int b){
  6. return a+b;
  7. }
  8. int Calc::mul(int a, int b){
  9. return a*b;
  10. }
  11.  
  12. CALCTEST.CPP:
  13. -------------
  14.  
  15. #include "stdafx.h"
  16. #include "Calc.h"
  17. #include <iostream>
  18.  
  19. using namespace std;
  20. using namespace System;
  21. using namespace System::Text;
  22. using namespace System::Collections::Generic;
  23. using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
  24.  
  25. namespace CalcTest
  26. {
  27. [TestClass]
  28. public ref class CalcTest
  29. {
  30. private:
  31. TestContext^ testContextInstance;
  32. public:
  33.  
  34. #pragma region Additional test attributes
  35. #pragma endregion
  36.  
  37. [TestMethod]
  38. void TestMethod1()
  39. {
  40. Calc c;
  41. int r1 = c.sum(1,2);
  42. int r2 = c.sum(2,3);
  43.  
  44. if( r1==3 && r2==4 ) {
  45. std::cout<<"Correct!";
  46. }
  47.  
  48. Assert::AreEqual<int>(4, c.sum(1, 2));
  49. }
  50.  
  51. [TestMethod]
  52. void TestMethod2()
  53. {
  54. Calc c;
  55. Assert::AreEqual<int>(3, c.sum(1, 2));
  56. }
  57.  
  58. [TestMethod]
  59. void TestMethod3()
  60. {
  61. Calc c;
  62. Assert::AreEqual<int>(2, c.mul(1, 2));
  63. }
  64. };
  65. }
  66.  
  67. BATCH SCRIPT:
  68. -------------
  69.  
  70. SET projdir=C:\Users\abudhaks\Documents\Visual Studio 2010\Projects\CalcProject
  71. SET chrome=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
  72.  
  73. REM Triggering OpenCover
  74. "C:\Users\abudhaks\AppData\Local\Apps\OpenCover\OpenCover.Console.exe"^
  75. -register:user^
  76. -target:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"^
  77. -targetargs:"/noresults /noisolation /testcontainer:\"%projdir%\Debug\CalcTest.dll\""^
  78. -mergebyhash^
  79. -showunvisited^
  80. -output:"%projdir%\CoverageReport.xml"
  81.  
  82. REM Creating a report directory
  83. MKDIR "%projdir%\report"
  84.  
  85. REM Triggering ReportGenerator
  86. "C:\Users\abudhaks\Downloads\ReportGenerator_1.9.1.0\bin\ReportGenerator.exe"^
  87. -reports:"%projdir%\CoverageReport.xml"^
  88. -targetdir:"%projdir%\report"^
  89. -reporttypes:Html,HtmlSummary^
  90. -sourcedirs:"%projdir%\CalcProject"
  91.  
  92. REM Opening the report
  93. "%chrome%" "%projdir%\report\index.htm"
  94.  
  95. pause
Advertisement
Add Comment
Please, Sign In to add comment