Click here to Skip to main content
15,895,471 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ShowNotifyBaloon problem Pin
Chuck O'Toole6-Sep-11 10:25
Chuck O'Toole6-Sep-11 10:25 
GeneralRe: ShowNotifyBaloon problem Pin
MicroVirus6-Sep-11 15:45
MicroVirus6-Sep-11 15:45 
GeneralRe: ShowNotifyBaloon problem Pin
_Flaviu7-Sep-11 7:15
_Flaviu7-Sep-11 7:15 
GeneralRe: ShowNotifyBaloon problem Pin
Chuck O'Toole7-Sep-11 13:05
Chuck O'Toole7-Sep-11 13:05 
Question"The system cannot find the file specified" Pin
AndrewG12312-Sep-11 12:07
AndrewG12312-Sep-11 12:07 
AnswerRe: "The system cannot find the file specified" Pin
Cheongwadae2-Sep-11 17:34
Cheongwadae2-Sep-11 17:34 
QuestionIntroducing tests into a legacy application? Pin
Stefan_Lang1-Sep-11 22:18
Stefan_Lang1-Sep-11 22:18 
AnswerRe: Introducing tests into a legacy application? Pin
Orjan Westin1-Sep-11 23:10
professionalOrjan Westin1-Sep-11 23:10 
The idea of unit tests is to test the functionality of units, as opposed to whole systems. (I assume you've read the relevant Wikipedia page.)

It's not as widely talked about in relation to C++ as some other languages (notably Java, but also C# and 'new' dynamic languages like Python, Ruby and that ilk) because
a) there isn't an established practically-standard unit testing framework, and
b) the language does not support reflection.

You can roll your own little framework, or grab one of the many free ones available. See Exploring the C++ Unit Testing Framework Jungle for a decent run-down. At my current workplace we use Boost.Test, but I've used CppUnit in the past. They both work, but are clunky when compared with, say, NUnit for C#.

Now, the idea is to test a unit, so you have a separate test application that links in the unit(s) you want to test, and work to their public interfaces. It's usual to have a setup-test-teardown structure, as you might need to create mock objects to pass in, or otherwise set up an environment to run the test.

So next time you need to make a change to this old legacy application, you start with identifying what units/modules/classes you need to change, and then sit down and make a series of tests that test them. For it to be any use, you need to have a comprehensive test suite - if you test only the behaviour on one sanitised input your test has poor coverage.

You want to be sure that you exercise the whole module, and all execution paths. This means testing for failures, to make sure that bad inputs or invalid environment setups generate appropriate failures (exceptions or error return codes). Test the edge cases, test "obviously" bad calls (for instance all functions that take int parameters that are assumed to be always positive - what happens when you pass in -1?) and test unlikely (but possible) combinations of inputs.

So you make your tests, and you check that they pass. If they don't pass, you need to figure out if the test is poorly written, or if there is a bug in the unit.

If you were fixing a bug in the unit, write a test that exercises that bug. In other words, write a test that will fail with the existing code. That way, you can verify that you've fixed the bug, since the test should pass after you're done.

Oh, and something that's often left out of the list advice - presumably because the adivsors see it as self-evident - is that you shouldn't remove tests. This means that for every bug you find and fix, the list of tests should grow, as you write a test to prove there's a bug, and then proves you've fixed the bug. Only remove a test if an interface has changed so the call doesn't compile any more. If that happens, write a new test to replace it.

Hope this helps a bit
GeneralRe: Introducing tests into a legacy application? Pin
Stefan_Lang1-Sep-11 23:59
Stefan_Lang1-Sep-11 23:59 
GeneralRe: Introducing tests into a legacy application? Pin
Orjan Westin2-Sep-11 3:30
professionalOrjan Westin2-Sep-11 3:30 
GeneralRe: Introducing tests into a legacy application? Pin
Stefan_Lang2-Sep-11 4:01
Stefan_Lang2-Sep-11 4:01 
GeneralRe: Introducing tests into a legacy application? Pin
Orjan Westin2-Sep-11 3:45
professionalOrjan Westin2-Sep-11 3:45 
QuestionText drawing is not getting properly Pin
Amrit Agr31-Aug-11 3:15
Amrit Agr31-Aug-11 3:15 
AnswerRe: Text drawing is not getting properly Pin
Alan Balkany31-Aug-11 4:10
Alan Balkany31-Aug-11 4:10 
AnswerRe: Text drawing is not getting properly Pin
xrg_soft@163.com31-Aug-11 6:16
xrg_soft@163.com31-Aug-11 6:16 
GeneralRe: Text drawing is not getting properly Pin
Amrit Agr1-Sep-11 22:50
Amrit Agr1-Sep-11 22:50 
GeneralRe: Text drawing is not getting properly Pin
xrg_soft@163.com5-Sep-11 18:13
xrg_soft@163.com5-Sep-11 18:13 
Questionconvert a C app to an MFC based Windows app Pin
Angela201231-Aug-11 3:00
Angela201231-Aug-11 3:00 
QuestionHow to learn C++ Pin
shanmugarajaa30-Aug-11 18:16
shanmugarajaa30-Aug-11 18:16 
QuestionRe: How to learn C++ Pin
David Crow31-Aug-11 2:41
David Crow31-Aug-11 2:41 
AnswerRe: How to learn C++ Pin
Chris Losinger31-Aug-11 3:02
professionalChris Losinger31-Aug-11 3:02 
GeneralRe: How to learn C++ Pin
Albert Holguin31-Aug-11 8:22
professionalAlbert Holguin31-Aug-11 8:22 
AnswerRe: How to learn C++ Pin
Nemanja Trifunovic31-Aug-11 6:10
Nemanja Trifunovic31-Aug-11 6:10 
GeneralRe: How to learn C++ Pin
Albert Holguin31-Aug-11 8:25
professionalAlbert Holguin31-Aug-11 8:25 
GeneralRe: How to learn C++ Pin
Orjan Westin31-Aug-11 23:37
professionalOrjan Westin31-Aug-11 23:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.