0

I am looking for VSCode extension, that runs all the tests I have in my project in one click. See the example below, to see what I really mean.

Example

Let's say I have a couple of files, that I want to run tests from:

Eg:
1.Test_input_1.txt
2.Test_output_1.txt (Correct output for Test_input_1.txt)
3.Test_input_2.txt
4.Test_input_3.txt (Correct output for Test_input_1.txt)

Once I click the run button, I want to check my program against all given inputs and outputs.

Any suggestions are welcomed!

Gama11
  • 31,714
  • 9
  • 78
  • 100
bubesh p
  • 95
  • 2
  • 8
  • 1
    VS Code has support for CTest, Google Test, Boost.Test, and Microsoft Native Test Framework. Take a look at this extension: https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer – Stf Kolev Dec 02 '19 at 12:23

1 Answers1

1

Look s like you have confused two different things. Quoted example refers to situation where actual tests has been written using some library like: CTest, Google Test, Boost.Test. Using this tools you have to write separate code which tests production code (you can read about TDD - Test driven development).

You have included a list of text files which are feed to standard input using for test cases on sites like: SPOJ, Hackerrank and so on. On this sites different programing languages can be used. To verify correctness of provided solution standard input and output is used. This is a quick simple way to verify correctness of programs created in almost any language, but this solution is not very usable in real life software development.

AFAIK there is no tool which can help you to do it quickly.

By refactoring your code you can take advantage of one of the tools and at the same time use those files.

int problemSolver(std::istream& in, std::ostream& out)
{
}

#ifndef TESTING_MODE
int main()
{
    return problemSolver(std::cin, std::cout);
}
#else

TEST(ProblemSolverTest, input1)
{
    std::istringstream in{ load_file("Test_input_1.txt") };
    std::ostringstream out;

    ASSERT_EQ(problemSolver(in, out), 0);

    auto result = out.str();
    ASSERT_EQ(result, load_file("Test_output_1.txt"));
}

...

#endif // TESTING_MODE
Marek R
  • 32,568
  • 6
  • 55
  • 140