PDA

View Full Version : Webinar (سمينار در وب) در مورد Unit Testing



JavanSoft
چهارشنبه 23 بهمن 1392, 23:15 عصر
اين وبينار در تاريخ 23 بهمن 92 برگزار شد
از انجايي كه امكانات جديد Unit testing در دلفي معرفي گرديد ، براي اشنايي دوستان لاگ سوالات مطرح شده را قرار دادم
مسئول برگزاري سمينار گفت كه بزودي لينك مشاهده امكانات را ارسال مي نمايد ، كه در پستهاي بعد خواهم گذاشت
اميدوارم براي علاقمندان مفيد باشد



Questions Log C:\Users\Vakili\Desktop\QuestionsLog 2014_02_12 23_57.rtf

Audience Question:
Q: Has Nick unit tested his unit testing presentation?
A: I have -- don't worry. ;-)

Audience Question:
Q: Where/when can I buy Nicks latest book ?
A: It will be available in print very soon. Electronically, it is only available to XE5 customers.

Audience Question:
Q: are the unit tests also available in xe?
A: Unit testing can be done in all versions of Delphi.

Audience Question:
Q: Greetings.
A: Hello, thanks for joining us. The webinar will begin in about 30 minutes.

Audience Question:
Q: Hi, will this webinar be generally about unit testing or is it more specific about XE5 and DUnitX ? I am still on D2007 due to some third-party libraries.
A: It is about unit testing in general. That includes coverage of tools that will work on D2007, but some of the tools and libraries (including DUnitX) require a newer version of Delphi. You will most likely learn something you can use with D2007.

Audience Question:
Q: how much more time???
A: Should be about 15 more minutes.

Audience Question:
Q: You really, really, really need to make a webminar about android gadgets like Glass, Drones and so on...
A: I did, last month. https://www.embarcadero.com/rad-in-action/programming-devices-and-gadgets Check out my blog too: http://delphi.org/

Audience Question:
Q: oooo, sorry, i missed. will check while waiting
A: It was a lot of fun. I'm looking forward to doing more similar content.

Audience Question:
Q: how about a gift copy to online participants?
A: There is a white paper that is an except from the book. You should have gotten a download link.

Audience Question:
Q: Re: Nick's book and "Electronically, it is only available to XE5 customers. " I am an XE5 user. Is it available electronically now? I keep checking and his site says it's done but unpublished.
A: Yes. RAD Studio and Delphi XE5 registered users can download it from http://cc.embarcadero.com/item/29670

Audience Question:
Q: that's a rock in Norway!
A: Got most of these images from Shuttestock.com

Audience Question:
Q: Haha, an "except" from the book. Coders eh... :-)
A: We had a little delay with the unit testing white paper excerpt from the book. We'll include a download link for it in the webinar follow-up email.

Q: I think i late
A: Just a couple minutes.

Audience Question:
Q: what is friendly class?
A: A "Friendly" class would be one that doesn't require any external entity, something like TStringList, etc.

Audience Question:
Q: could you explain more about "code coverage tool" ?
A: https://code.google.com/p/delphi-code-coverage/

Audience Question:
Q: Can I record webinar?
A: We will send a link to watch a replay of the webinar in the follow up email within the next week

Audience Question:
Q: *you're*
A: Ouch! I'll fix that.

Audience Question:
Q: Sorry but with the black background it's had to read!
A: Sorry. That background is so normal to me that I forgot to change it.

Q: I think the screen is too small, I have to change zoom

Audience Question:
Q: I'm curious: Did you learn your testing techniques formally or the hard way?
A: LOL -- the hard way. :-) Try to maintain a bunch of untestable code and you get to be a believer.

Audience Question:
Q: Any suggestions for adding unit tests to legacy code, especially legacy procedural code?
A: I'll discuss this in the Q&A at the end, because you won't be the only one to ask this. ;-)

Audience Question:
Q: could you publish a real test with a little context? calc samples are always thing ...
A: There will be some more substantive examples coming up.

Audience Question:
Q: Comment: The calculator is to unit testing what "Hello world" is to programming your very first application. Why does everybody introduce unit testing with a calculator? ;-)
A: Easyt to do and illustrate. ;-)

Audience Question:
Q: How many tests are enough for... calculator? :)
A: Depends on how complicated you want the calculator to be. ;-)

Audience Question:
Q: I can see all tests compare the results from functions with values I am expecting to receive from them.
What if I have a procedure (no value is returned) I want to check instead ? How can I test it ?
A: For procedures, you can make sure that they don't raise any exceptions that they aren't supposed to and that they do raise exceptions that they are supposed to.

Audience Question:
Q: Is it a cardinal sin to write one test method that is called with a set of parameters, say (X, Y, and E) and call it in from a loop that feeds it data from a table?
A: No, in fact, DUnitX supports doing that through attributes.

Audience Question:
Q: Hey Nick! While I absolutly agree that unit is they best way to keep your code from becoming pain in the butt legacy code, I find your example very idealistic. I would propose there's a miniminal Coding testing developing for people that have limited resources and time where by your example calculator test would be
A: Okay -- I agree the Calculator is a bit simplistic, but I do think writing tests like I am is the best way to go. They are much easier to maintain that way.

Audience Question:
Q: Comment: I guess if you want to use procedures, those procedures do stuff on other objects. Isn't that where Mocks come into play? That they test, if the rights things are done to them?
A: Yep.

Audience Question:
Q: so I can't test it with all possible values?
A: YOu can -- you just need to input data. I didn't demo this, but you can set up a group of tests via test data.

Audience Question:
Q: Its seems really hard and slowly way to test a big project... and it can be more slowly within a database
A: Only test the code that you want to work properly. If you don't care whether it works properly, don't test it. ;-)

Audience Question:
Q: Sorry I joined late so this could be dumb question.. Is the teardown guaranteed to be called? or could we have memory leaks?
A: TearDown will be called after every individual test.

Audience Question:
Q: again on the procedures: Does this means that if I have procedures that do calculations and I want to check these calculations then I have to transform them into functions and then check the relevant results ?
A: Not entirely sure what you are getting at -- if you are doing calculations, then you are in a function, right? Unit testing also encourages you to write functions and not procedures.

Audience Question:
Q: Can expected value be a mrOK clicked in by a human user, checking screen resolutions, fonts etc? Running tests on Grandmother's computer and Grandson's!
A: Bruce - Unit tests should run with no user intervention.

Audience Question:
Q: Is there a way to test user interface behavior this way?
A: No -- UI should be tested with tools like TestComplete. But your UI should be a very thin layer over your code so you feel little need to test it.

Audience Question:
Q: Could you show how not to write tests? I mean bad example of a test.
A: Bad tests would have lots of Asserts in one test, expect tests to run in a specific order. Try to cram too much into a single test, etc.

Audience Question:
Q: sorry, I wasn't clear, when I said "procedures that do calculations" I meant procedures that do calculations retrieving data from a DB, do some operations and writing other data on the DB afterwards. That is what I meant for "doing calculations". However, you have answered to my question
A: Okay, thanks for clarifying.

Audience Question:
Q: I really have problem with your screen resolation ... sometimes i cant see screen side and sometimes I cant see the codes .. hope you can fis it in next webinar :)
A: I'll work on it. Sorry

Audience Question:
Q: Can DUnitX be used to test non visual components or entities like a data module ?
A: It could, yes. But then you are doing integration testing (which is fine).

Audience Question:
Q: This is actually the very first time I see DUnitX in action. Is there something like an official tutorial on it? I still hope I was just unable to find one.
A: No official tutorial, but it is pretty easy to figure out from the examples/demos.

Audience Question:
Q: So the question becomes: can we extend the concept to protect code we write to handle GUIs? Automating the user if necessary for religious reasons - but a test gets a pass if the GUI is legible, etc so human judgement is preferable.
A: Unit testing will only test code, not GUIs.

Audience Question:
Q: Why do you add the procedure begin around the Raise call ?
A: That's an anonymous method.

Audience Question:
Q: Do you know ways for fuzzing input data (user or file based) for tests?
A: Not sure what you mean -- can you clarify?

Audience Question:
Q: How can you use this framework to test user interfaces?
A: You can't -- it's for testing code only.

Audience Question:
Q: Have you used Design of Experiments in writing Unit Tests?
A: Sorry, I confess I don't know what that is.

Audience Question:
Q: can I test private functions ?
A: You can't -- and you shouldn't want to. If you feel the need to test them, then they should be public, right?

Audience Question:
Q: CheckEquals(4,Add(2,2),'2+2 = 4')
A: Harder to maintain and read, but easier to write.

Audience Question:
Q: This is excellent, it reflects something I did for a compiler I wrote; thousands of independent tests that I could run easily whenever I wanted. It really exposed a ton of bugs before any customers were subjected to them. That experience made me want to do this more extensively in other ways, which is why I'm happy to see this webinar!
A: :D

Audience Question:
Q: You can test part of the user interaction if you abstract that code using MVVM. Then you can unit-test the VM part. See the example from Blaise Magazine that is now also at https://bitbucket.org/sglienke/dsharp/src/1c0603fea51d39ab12fc349ca0baad9a037aa4d3/Samples/PresentationModel/MindScape_AppView_StepByStep/?at=feature/Caliburn
A: Yes, exactly. Everyone should use MVVM. Malcolm Groves had a CodeRage presentation on the subject too.

Audience Question:
Q: What you prefer after finish unit testing .. how we can disable all of this tests?
A: You don't disable them, but they are not in the production project. Tests are in a different excutable sharing the common code of the Class Under Test.

Audience Question:
Q: A real world example is determining how many pair wise combinations are necessary to test a system, where the total possible tests are in the billions, but it will take only a couple hundred pair wise combinations to fully test the system
A: True

Audience Question:
Q: ahh, a short DOE explanation is having combinations of possible and not possible things for a project, sub-system, objects, a single object, etc.
A: True.

Audience Question:
Q: Same question for Delphi Mocks: TMock<> looks extremely interesting. Is there some tutorial you can recommend?
A: Nick has a blog post and his book covers it.

Audience Question:
Q: You can test part of the user interaction if you abstract that code using MVVM. Then you can unit-test the VM part. See the example from Blaise Magazine that is now also at https://bitbucket.org/sglienke/dsharp/src/1c0603fea51d39ab12fc349ca0baad9a037aa4d3/Samples/PresentationModel/MindScape_AppView_StepByStep/?at=feature/Caliburn
A: Malcolm Groves MVVM Links: 1) MVVM resource list - http://www.malcolmgroves.com/blog/?p=1340, 2) Malcolm's CodeRage 7 Replay - http://www.youtube.com/watch?v=Ci1HP8ZBJxk

Audience Question:
Q: Can i use all of this with C++‎‎Builder? or I will need another framework?
A: Stay turned to David I's blog.

Audience Question:
Q: "You can't -- and you shouldn't want to. If you feel the need to test them, then they should be public, right?" I'm not sure that's a valid argument. All code is falliible because it's written by a human. Remember, test all the code you care about working properly... if you don't bother testing privates in some way, it's bound to be broken.
A: You should test the public method that utilizes the private method.

Audience Question:
Q: Nick your book is excellent !! the best Delphi book i have read so far :)
A: Thanks very much!

Q: I think its a good Idea but the question is "is it finilaze?" I think we need more talks about it and you have to work on it ... its a lil bit hard :)

Audience Question:
Q: You can test part of the user interaction if you abstract that code using MVVM. Then you can unit-test the VM part. See the example from Blaise Magazine that is now also at https://bitbucket.org/sglienke/dsharp/src/1c0603fea51d39ab12fc349ca0baad9a037aa4d3/Samples/PresentationModel/MindScape_AppView_StepByStep/?at=feature/Caliburn
A: Download link to Malcolm's MVVM CodeRage 7 replay - http://cc.embarcadero.com/item/29161

Audience Question:
Q: Wouild love to see a more advanced version of this webinar, ie using ClientDataSet to mock data, Some substantial mocks etc.
A: That would be great. Check Nick's blog and book for more information.

Audience Question:
Q: How mature is DUnitX, it feels a little unfinished... I was browsing TCommandLine which looks unfinished, is there a roadmap for DUnitX? Or should commercial environments stick to DUnit for the time being until DUnitX becomes more mature
A: DUnitX is a little unpolished, but completely usable. The GUI runner is the main thing missing, but is not necessary. It has support for CI like Jenkins.

Audience Question:
Q: What code coverage tools are there for Delphi?
A: Check out https://code.google.com/p/delphi-code-coverage/

Audience Question:
Q: What code coverage tools are there for Delphi?
A: https://code.google.com/p/delphi-code-coverage/

Audience Question:
Q: Excellent presentation. Are the slides available for download?
A: We'll make them available.

Audience Question:
Q: What code coverage tools are there for Delphi?
A: Check out AQTime as well

Audience Question:
Q: is the DUnit only 32-bit in XE5?
A: No it will work on 64-bit and 2010 and newer.

Audience Question:
Q: Comment: The book certainly is truly excellent. It made me switch over to Spring4D collections within hours.
A: Great! Thanks!

Audience Question:
Q: Re: testing privates - maybe always arrange their declarations underneath public declarations... then surround the "PRIVATE" keyword in a conditional-compile directive, then a simple compile time switch can temporarily make all privates public so they can be unit tested in isolation.
A: OK

Audience Question:
Q: When is your book going to be publicly available?
A: It is today when you buy XE5, or the print version will be available via CreateSpace.com in a week or so.

Audience Question:
Q: Thank you for your presentation!
A: Introducing Delphi Mocks by Vincent Parrett - http://www.finalbuilder.com/Resources/Blogs/PostId/417/introducing-delphi-mocks

Audience Question:
Q: the sgbd question?
A: Not sure what you mean . . .

Audience Question:
Q: may be out of scope, but how can apply this to legacy systems based on sgbd stored procedures and triggers?
A: Use a mock via an interface to isolate your database layer code from the database.

Audience Question:
Q: What about setting up/tearing down a test database to have actual data access as your "mocking" layer?
A: THen that is integration.

Audience Question:
Q: AQTime is for code profilng...
A: AQTime Pro does coverage.

Audience Question:
Q: AQTime is for code profilng...
A: http://smartbear.com/products/qa-tools/application-performance-profiling/features/code-coverage-analysis/

Audience Question:
Q: Nick, I think the fuzzing question pertains to http://en.wikipedia.org/wiki/Fuzz_testing
A: THanks!

Audience Question:
Q: CCValidator is very good object for fuzzy test :)
A: Interesting

Audience Question:
Q: Simply speaking, fuzzing changes your correct data or parameters, for instance to test data validator methods. Ex.: expression parser is called a number of times, each time with somewhat changed base expression.
A: Interesting

Audience Question:
Q: how can buy your book "Coding in Delphi" ?
A: If you have XE5 you can download the PDF electronic version of Coding in Delphi - from the registered user downloads area. Otherwise, wait for the printed book and buy it via Nick's link.

Audience Question:
Q: I believe you CAN test private method. As long as they are not 'strict private' then if you just put a 'helper class' in the same physical unit as the class under test, and use it's public methods to access the otherwise unaccessible private methods of the original class, then you can test the private methods of the original class without modifying it (such as redeclaring private methods as public)
A: Interesting

Audience Question:
Q: useful about the code coverage
A: AQTime Pro version - http://smartbear.com/products/qa-tools/application-performance-profiling/features/code-coverage-analysis/

Audience Question:
Q: What HTMLWriter are you using?
A: That is one Nick wrote.

Audience Question:
Q: how can I switch from the "traditional" way of programming into the "Unit testing orientated" one more efficiently ? What are the practical advices you would give to a traditional programmer eager to switch ?
A: Use Test Driven Development to write your code. Check out Malcolm's MVVM presentation.

Audience Question:
Q: what about using this on ios mac os etc
A: DUnitX supports OS X. If you are running your tests in isolation then you can test your mobile code on the desktop.

Audience Question:
Q: When is available the printed book in Nick' link ?
A: Nick said in the next week or so.

Audience Question:
Q: On database testing, you could always have a dedicated database to test the unit that accesses and uses SQL
A: THat would be integration testing, which is a good idea, but not unit testing.

Audience Question:
Q: Does Nik use the open source code coverage tool?
A: He does.

Audience Question:
Q: i´m not familiar to code coverage, could you explain quickly what is it?
A: It tracks code that is executed as you use or test your software. Shows source lines that are not executed.

Audience Question:
Q: in your experience, you can say that you are more productive? could be a dumb question, but tdd will not double the coding time?
A: It might double or increase the coding time, but greatly decreases the overall time (maintaining, bug fixing, etc.)

Audience Question:
Q: What's the open source code coverage tool called?
A: https://code.google.com/p/delphi-code-coverage/

Audience Question:
Q: Any statistics on maintenance time reduction from TDD?
A: There are, but don't have any on hand. Look online.

Audience Question:
Q: Nick's link to buy printed book "Coding Delphi"
A: Not available yet. Watch his blog.

Audience Question:
Q: Does "Easy to unit test" mean interfaces should always be used. Seems easier to mock an interface than a class?
A: Yes, coding against interfaces is recommended for good development as well as testing.

Audience Question:
Q: Can you speak more about testing legacy code. all procdural. lots of spaghetti. where to start? next steps?
A: Check out "Working with Legacy Code" by Michael Feathers

Audience Question:
Q: Can you speak more about testing legacy code. all procdural. lots of spaghetti. where to start? next steps?
A: http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052

Audience Question:
Q: Does code coverage tool work with Delphi 2007?
A: From https://code.google.com/p/delphi-code-coverage/ -> DCC is compatible with Delphi 2010, XE and XE2 (32-bit), Delphi 2006, Delphi 5. If you find that it works for other Delphi versions, please let us know so that we can add to the list.

Audience Question:
Q: Does DUnit memory leak checking work in your experience?
A: AQTime Pro does leak checking on windows.

Audience Question:
Q: Any strategies to test large code bases that currently have no tests (projects that are not loosely coupled)? My current strategy is to test objects with no dependencies and chip away introducing loosely coupled code where I can...
A: Look for a seam, and test new code.

Audience Question:
Q: what do you use for leak detection
A: Use FastMM

Audience Question:
Q: Do you use Unit tests for performance testing ?
A: No. It doesn't cover performance.

Audience Question:
Q: Does dunix works for mobile compiler ?
A: Works for Mac and Windows. Create a Windows target for your mobile apps.

Audience Question:
Q: Memory leak checking does work in DUnit and works very effectively... you can register expected memory leaks for things like Indy (or choose not to use Indy)
A: :D

Audience Question:
Q: Actually FastMM is integrated with DUnit
A: :D

Audience Question:
Q: Please elaborate on the idea that just came up. Putting a unit test in the very same unit as the tested class? The motivation seems to be able to test private methods.
A: Answered by Nick

Audience Question:
Q: Question: Wouldn't leak testing in your tests make it pretty easy to find out WHERE the leak was caused instead of just knowing there is a leak?
A: Yes

Audience Question:
Q: try test1 excerpt call.Nick; end;
A: :D

Q: tanx Nick ..