Figuring Out How to Test Code
-
I've been familiar with C++ for a few years now but I can't seem to think of a good solution for debugging my code. Can anyone make a suggestion?
-
I've been familiar with C++ for a few years now but I can't seem to think of a good solution for debugging my code. Can anyone make a suggestion?
-
I should probably have mentioned. It's a class file, not a full program. I'm using Visual Studio Code and the Debugger wants an executable to run but I haven't even compiled the file.
-
I should probably have mentioned. It's a class file, not a full program. I'm using Visual Studio Code and the Debugger wants an executable to run but I haven't even compiled the file.
Then you have first to compile and link it! BTW, is this file already a part of some project?
-
I should probably have mentioned. It's a class file, not a full program. I'm using Visual Studio Code and the Debugger wants an executable to run but I haven't even compiled the file.
You cannot test a class file in isolation, it must be part of an executable. And if you have not even compiled it yet, you are quite a way from that step. I would suggest getting a copy of Visual Studio 2017 (free from Microsoft) and using the tools that come bundled with that.
-
I've been familiar with C++ for a few years now but I can't seem to think of a good solution for debugging my code. Can anyone make a suggestion?
Between your subject and your post it is not clear what you want to do. If you want to formally 'test' your code then 1. Research unit test libraries and select one 2. Add the library to your project (not part of production delivery) 3. Use the library and write unit test code to test both happy path, boundaries and failure cases. 4. Run the unit tests. If you want to information test your code then 1. Create ANOTHER project 2. COPY your class to it 3. Add a second class with a main method 4. Write a number of methods that exercise the code. 5. Build and run it. 6. If you make changes copy it back. If you already know the class has a problem and you cannot not determine what the problem is 1. Find a way to replicate the problem (see two above examples.) 2. As per the other posts find a debugger and figure out how it works. 3. Step through your code in the debugger to find the problem. Note that if you have large application and you already know that your class is failing then attempting to debug the entire application just so you get to the class is not very effective.
-
I've been familiar with C++ for a few years now but I can't seem to think of a good solution for debugging my code. Can anyone make a suggestion?
Do you think is there any other or rather say faster way to remove the bug from solution! I doubt there is any. I remember when I don't know how to debug the MFC application, I used to put MessageBox to identify the pain areas. You think how many time have to run application just to point the pain location, if I know how F9,F5 and F10 work at that time, my time would be reduced by 99% in my case.
-
I should probably have mentioned. It's a class file, not a full program. I'm using Visual Studio Code and the Debugger wants an executable to run but I haven't even compiled the file.