четверг, 13 февраля 2014 г.

Q&A вебинара Ника Ходжеса

Цитирую:



Audience Question
Q: Hello from Turkey
A: Hello!



Audience Question
Q: hello, anybody around?
A: We are here - getting ready for the 6am PST start



Audience Question
Q: hello
A: Welcome



Audience Question
Q: Good morning to you.
A: Welcome



Welcome to this Embarcadero webinar event!



Audience Question
Q: hi
A: Hi!



Audience Question
Q: I saw the volume bar move - but hear nobody talking yet.
A: We will be starting soon



Audience Question
Q: Hi all
A: Hello!



Audience Question
Q: I'm just going to join in saying hello.  Hi from Romania!
A: Hello from Pennsylvania!



Audience Question
Q: It will start about now, right? (I love timezones)
A: Yep, very soon now.



Jim McKeeth (to All - Entire Audience):
Starting shortly.



Audience Question
Q: Good morning for everyone from Poland !
A: :D



Audience Question
Q: We are also on the line from Denmark
A: :D



Audience Question
Q: Will there be an ebook version in a couple of weeks too, or just hardcover?  I would like to read it on my iPad (physical paper is so 2013 ;)
A: There will -- after the deal  with EMBT, I will sell the book on LeanPub.



Audience Question
Q: will this webinar be downloadable?
A: Yes, there will be a replay downloadable later.



Audience Question
Q: Dutch Embarcadero office is online too:-)
A: :D



Audience Question
Q: Hi Jim, from Santa cruz de la Sierra Bolivia
A: Good morning!



Audience Question
Q: yes please release a iphone/ipad version
A: It will come out as PDF, EPUB, and MOBI



Audience Question
Q: Are the slides  meant to be visible yet?
A: all is visible



Audience Question
Q: will this webinar be recorded for the benefit of everyone?
A: yes



Audience Question
Q: pleas erelease a ipad/iphone version of the book
A: An ePub version will be available.



Audience Question
Q: Will you upload this video somewhere?
A: You will get an email with a replay link.



Audience Question
Q: I know this is Delphi-related, but do any of these frameworks work with C++Builder too?  I think DUnit does - but DUnit2, DUnitX, the mocking framework you just mentioned, ...?
A: David -- I don't know -- I don't do C++ at all.  Perhaps someone else will know.



Audience Question
Q: Copying code -> clipboard inheritance.  :)
A: :-)



Audience Question
Q: In which version was included the DUnitX to Delphi ? I can't find it in Delphi XE3 Architect.. :(
A: It's not included with Delphi.  It's available at https://github.com/VSoftTechnologies/DUnitX



Audience Question
Q: Will you upload this video on youtube ?
A: I believe this will end up on YouTube, yes.



Audience Question
Q: Does DUnitX is available for Delphi 7 Professional ?
A: No -- DUnitX requires language features only available in XE and up.



Audience Question
Q: What happens if you Add(MaxInt,MaxInt)
A: Only one way to find out.  :-)



Audience Question
Q: dUnitX looks like a port of JUnit :)
A: I assume you mean that as a complement.  :-)



Audience Question
Q: Can these testing frameworks be used in C++Builder?
A: I confess that I don't know for sure, but I don't see why not.



Audience Question
Q: Did you copied or linked Unit8 into the test project?
A: I used the unit after adding it to the project.



Audience Question
Q: Setup / Teardown seem inconsistent to the delphi Create / Destroy(or free) methods - though their use seems similar.
A: Setup and TearDown are called for every test -- so they will be called many times for each testfixture.



Audience Question
Q: ok, but is it a copy? if so I have to always keep the copy of Unit8 up-to-date..
A: No, it's not a copy, it's a reference to the one file.



Audience Question
Q: Hello from italy
A: Hello!



Audience Question
Q: Is that presentation will be available on Youtube as video ?
A: I believe so.



Audience Question
Q: Does "WillRaise" ignore handled exceptions?
A: No -- it checks and sees if the exception is raised whether you handle it or not.



Audience Question
Q: Can you output the results of DUnitX to XML so it can be used (or visualized) in Continuous Integration servers like Jenkins? Preferably in a format like NUnit does, so no special plugin have to be used in Jenkins.
A: Yes, DUnitX has an NUnit output runner.



Audience Question
Q: How to "remove" the expected exception ? By assigning "nil" to ExpectedException ?
A: ExpectedException is true only in the method where it is assigned.



Audience Question
Q: Hmmm i am not getting any of the slides, voice is fine. Looks like I may have to wait for the download version ...
A: Sorry you are having video issues. There will be a replay.



Audience Question
Q: Can Delphi-Mocks be used with DUnit, or is it just for DUnitX ?
A: You can use Delphi Mocks with both DUnit and DUnitX



Audience Question
Q: Is this also working if the interface is not an IInvokable?
A: No -- I should have mentioned that and didn't.  Your interface has to be a descendent of IInvokable.



Audience Question
Q: Is there a IDE expert planned for DUnitX that can run the tests from within the IDE (like in Visual Studio), instead running an external executable with the tests compiled in. Tests would have to be compiled into dll's instead of exe's.
A: I don't know what is on the roadmap for DUnitX, but that is a great idea.



Audience Question
Q: shouldn't the logger be in the Setup/TearDown instead of the arrange phase?
A: Probably, but that is harder to demo.  ;-)



Audience Question
Q: I missed the Dependency Injection topic (like Spring4D) to make your code testable or is that another webinar? :) On that note, can your unit tests depend on the DI, or should you try to avoid that?
A: That would be another webinar. Check out Nicks book and Blog. Tests can depend on DI, but should should use Mocks.



Audience Question
Q: I know this is Delphi-related, but do any of these frameworks work with C++Builder too?  I think DUnit does - but DUnit2, DUnitX, the mocking framework you just mentioned, ...?
A: CUnit is supported with C++Builder.  I'll look to see what you might use for Mock Libraries in C++.  I will work on a blog post.



Audience Question
Q: FinalBuilder or Jenkins are good automated build tools. If anyone wants to know.
A: Thanks



Audience Question
Q: Will we get a copy of slides?
A: Yes



Audience Question
Q: Good names make code easier to read and understand months, and years along the path.
A: Yes - using comments and well thought out names for functions, fields, objects, etc will really help.



Audience Question
Q: How do you mock out a TDataset? There is no IDataset standard in Delphi.
A: Good example of creating a mock manually. Or don't tie your code to tightly to the dataset.



Audience Question
Q: Is it possible to check exceptions also by value (eg. Message oder ErrorCode) and not by class only?
A: Nick believes so. Interesting question. You could check the value of the error code. There may be functionality for that.



Audience Question
Q: How would you implement GUI Testing in Delphi?
A: Use a 3rd party tool like Test Complete.



Audience Question
Q: Hi. Is there a good way to test if ansistrings are equal in dunit
A: Yes, CheckEquals or your own.



Audience Question
Q: In regards to above - Perhaps it'd be a good idea for the future to inform us using GMT as well as PST, so the european viewers will have less trouble finding out the correct starting time?
A: ok



Audience Question
Q: Does DUnitX support FMX in that can the tests be run on OSX and the mobile targets?
A: Not sure.



Audience Question
Q: Do you use Unit Testing for database objects like Stored Procedures and Functions?
A: We had a session back in DataRage 1 - "Writing Unit Tests for SQL Databases using Delphi"- http://edn.embarcadero.com/article/39499



Audience Question
Q: Is there an ETA for the GUI runner for DUnitX?
A: Not sure. It is open source, so it depends on the contributions.



Audience Question
Q: To avoid Copy Paste you can use Data Driven Test with the TTestCase attribute in DUnitX
A: Good point.



Audience Question
Q: How would you suggest "selling" unit tests to my team?  I work in a very conservative dev environment, and so only use them myself in my private non-work projects.  How can I sell their value?  What's the key thing?  How do I handle their worries about spending extra time to develop something, because writing tests is "useless" time?
A: They save you time and reduce bugs.



Audience Question
Q: Ideally, if you wind up with duplicate code in tests, you would refactor the tests.
A: Good point.



Audience Question
Q: Assume a large Delphi project - vector editor that is not well OOP designed. Is it better to implement unit testing continuously, do full code rewrite at one time, or to not use unit testing for that kind of applications at all?
A: Difficult question to answer. Try to find seams to start ading tests.



Audience Question
Q: How much it the book. and what version of Delphi do I get with it? Sorry if this had be asked before I was called out of the webinar.
A: Available with any version of Delphi XE5. That is currently the only way it is available.



Audience Question
Q: is this recorded?
A: Yes



Audience Question
Q: Estimated time when DUnitX will have a GUI
A: https://github.com/VSoftTechnologies/DUnitX



Audience Question
Q: How do I remove test code (mocks, ...) when making production version. Do we use conditional compiling?
A: Conditional compilation is a good way.



Audience Question
Q: DUnit/X shown working in XE5. Do they work as well in earlier versions and are there any issues with DUnit/X in WIN8/8.1?
A: The demo was on Windows 8/8.1 It will work with some earlier versions, but needs to be Delphi XE and newer.



Audience Question
Q: DUnitX does supports Mac OSX but not current mobile platoforms, I commited that code a couple months ago.
A: Thanks!



Audience Question
Q: DUnitX is supports Delphi 2010 or later
A: Thanks!



Audience Question
Q: Can we somhow load test data from outside sources like TDataSet descendant in a loop instead of typing wright in code some constands?
A: Writing Unit Tests for SQL Databases using Delphi - http://edn.embarcadero.com/article/39499



Audience Question
Q: DUnitMock is XE2 or later
A: https://github.com/VSoftTechnologies/DUnitX - DUnitX is a new test framework, taking ideas from DUnit, NUnit and other test frameworks. It is designed to work with Delphi 2010 or later, it makes use of language/RTL features that are not available in older versions of Delphi.



Audience Question
Q: How can you convert your DUnit tests to DUnitX?
A: There is a compatibility unit in DUnitX that allows you to call Check instead of Assert. Makes migration easier.



Audience Question
Q: Best way to convince a developer - Have them try it for themselves.
A: :-)



Audience Question
Q: What tools can be used to measure Code Coverage in Delphi?
A: https://code.google.com/p/delphi-code-coverage/ and https://code.google.com/p/delphi-code-coverage-wizard/



Audience Question
Q: Can I use DUnit also without graphical-interface?
So I could embed a testing code (e.g. with random-vars) at the very start of my final application and let it only react, if the test fails.
This way the test would run automatically and the probability to find errors (in the combination of randomly-generated-args) would increase, I suppose...

A: Yes, there is a command line version



Audience Question
Q: How can you convert your DUnit tests to DUnitX?
A: https://github.com/VSoftTechnologies/DUnitX/blob/master/DUnitX.DUnitCompatibility.pas



Audience Question
Q: TVirtualInterface is in XE2, right? So Mocks should support it too
A: Yes, you are right.



Audience Question
Q: Making tests can also be bug-prone.  How can one avoid writing erroneous tests that give "properly operating" code that actually is wrong i.e. 2+2=5 shows "OK"?
A: Be careful. Write more than one test and unit tests are a different implementation



Audience Question
Q: You haven't answered my question about mixing production code and test code but it was asked by audience: use Data Driven Test with TTestCase ,,,
A: Never do that.



Audience Question
Q: Is there a way do run UnitTests on Android or iOS
A: Not yet.



Audience Question
Q: How can I test VCL Components?
A: Not with unit tests. Would need a GUI tool



Audience Question
Q: How to do Unittest on "Procedure" not Classes?
A: Yes



Audience Question
Q: You mentioned that one should only have one assertion per test? Why?  (I didn't get that)
A: To isolate your tests. When a test fails you want to know exactly what failed.



Audience Question
Q: How can I test a Form?
A: Use a GUI runner like Test Complete. You should test the code behind the form with unit tests.



Audience Question
Q: Link to that refactor of last coderage? (youtube,..)
A: Maintainable Code: Separating Logic from UI - http://www.youtube.com/watch?v=37hjA21OoRc



Audience Question
Q: Mocks requires interfaces or can be used with classes?
A: Yes.



Audience Question
Q: Use of moks is still quite "obscure" to me... And too quick in thies webinar... Is it explained deeply in your book?
A: There is a chapter devoted to using Mocks in Nick's book.



Audience Question
Q: How to do test on private procedure
A: Test the public procedure that calls the private.



Audience Question
Q: A different approach to testing a GUI is not a GUI runner, but a component test framework that tests the "code quality" of your forms / components. Eg, do actions have OnExecute handlers, have you named your components, etc.  Check out OpenCTF: http://sourceforge.net/projects/openctf/ and http://www.habarisoft.com/download/OpenCTFGettingStarted.pdf
A: Thanks



Audience Question
Q: What do you think about the SetupOnce and TearDownOnce to only have to create a database connection once for a suite of tests?
A: SetupFixture and TeardownFixture attributes



Audience Question
Q: Do the DUnitX guive the coverage of the tested unit?
A: Need to use https://code.google.com/p/delphi-code-coverage/



Audience Question
Q: is there any video to learn mock deeper ? a coderage session maybe ?
A: Nick's "Coding in Delphi" has a chapter devoted to using Mocks.



Audience Question
Q: DunitX is a topic at the Dapug Workshop in April in Denmark.. Nick will be there live, if anyone is interested... http://alt.dapug.dk/ws29042014.htm
A: :D



Audience Question
Q: Refactoring the Attributes of a Procedure will cause large Amount of refactoring of already written tests. Any Hints to keep that work as low as possible?
A: Nick doesn't necessarily agree. If you add new methods you need to test those methods.



Audience Question
Q: Where can we purchase Nick's book ?
A: You get a copy with Delphi XE5 or it will be on CreateSpace within a week.



Audience Question
Q: Is it possible to configure the DUnitX in order to raise a warining when two test cases with same input guive the same result? like duplicate tests or tests not deep enough !!
A: No.



Audience Question
Q: What is the name of "the book"?
A: "Coding in Delphi"



Audience Question
Q: Do we need extra project for testing unit or can we have all in one  project file?
A: Should be in a different project file. Don't mix production and tests.



Audience Question
Q: Does DUnitX integrate well wil continbuous build servers like Jenkins? Is it capable to output XML files that are compatible with Jenkins? We currently use a unit called XmlRunner2.pas together with DUnit.
A: Yes



Audience Question
Q: can all the links also be put on the page of the recording, so that they're available?
A: I will give the links to Product Marketing



Audience Question
Q: Thank you ...
A: Coding in Delphi code - https://bitbucket.org/NickHodges/codingindelphi



Audience Question
Q: What about legacy code which requires a lot of refactoring? Should it get unit tested to some degree? Is the effort worth it?
A: The purist would say yes. You decide. All new code you make shoudl be unit tested. Add tests when you can.



Audience Question
Q: What is the difference between Dunit and Dunit2
A: Unknown beyond support for newer editions of Delphi



Audience Question
Q: Somewhat unrelated - but would it be possible for Embarcadero to email a bit "less" - or combine mails into a weekly digest? Some weeks it feels like there's 5 or more mails coming in, sometimes as much as 3 a day...
A: we send out a monthly alert with several topics in it.  For each event we also send individual emails to targeted customers based on the topic.



Audience Question
Q: How can you test concurrency, like threads?
A: Yes, but it would be challenging.



Audience Question
Q: Is stubbing and mocking only possible in DUnitX, or also in DUnit?
A: Works with both.



Audience Question
Q: If you seperate production code and test code then you can introduce errors by copy/paste code?
A: The test should consume the production unit. That production unit is used in both places.



Audience Question
Q: Nice to note that you should only test your public methods. Don't put effort in the protected or private methods...
A: :-)



Audience Question
Q: Speaking about command line, how does the tool report that test failed or not ? By exit code ?
A: Believe so.



Audience Question
Q: I vote "yes" on the dependency injection webinar
A: :-)



Audience Question
Q: Can the unit tests be set up to test cross platform code as well? - e.g. firemoney code and it's results on windows, or iOS or Android.
A: Tests run on Windows and OS X.



Audience Question
Q: am I missing the point if I think the dataset mock could internally contain a TClientDataset?
A: You could do it that way.



Audience Question
Q: Delphi Code Coverage has not seen any updates since 1.5 years and I experieced exceptions inside Delphi Code Coverage which prevented me to use it. Are there any alternatives?
A: AQTime Pro does code coverage - http://smartbear.com/products/qa-tools/application-performance-profiling/features/supported-applications-technologies/delphi-profiling/



Audience Question
Q: How can one be sure that enough test cases have been added?
A: You can't. Check code coverage, but beyond that your suite will be ever expanding.



Audience Question
Q: Where would you start when trying to bring a RAD style project (code in the form) under code testing.
A: Add test for new code. REfactor what you can.



Audience Question
Q: Could/Will DunitX be integrated/shipped into Delphi as well in the future?
A: Maybe.



Audience Question
Q: Is it possible to configure the DUnitX in order to raise a warining when two test cases with same input guive the same result? like duplicate tests or tests not deep enough !!
A: Good idea. Not currently implemented.



Audience Question
Q: Do you agree that because of 80 - 20% rule (20 % of code runs 80 % of time) it is best to test only that 20% of code?
A: Start with the 20% and work toward testing 100% of the code.



Audience Question
Q: I am sorry if I missed the answer but is Delphi Code Coverage tool non-dependant of Unit test framework or is it only comaptible with DelphiUnitX
A: It is completely independent of framework.



Audience Question
Q: CodeCoverage does not cover generics very well
A: OK



Audience Question
Q: You can create 2 interfaces at the "databases" - one for "real" data and one for a "mock" sets of clientdataset - the second without writing any data back - so that you will "read" the same "database" data every time you test. Helps me alot in debugging data dependencies.
A: THanks



Audience Question
Q: Testing floats / extended might be nice at this point.
A: DUnit and DUnitX have routines for dealing with them. You need to use a tollerance/epsilon to allow for margin of error.



Audience Question
Q: Link to that refactor of last coderage? (youtube,..)
A: CodeRage 6 - Delphi, Dependency Injection, and Spring Framework - http://cc.embarcadero.com/item/28573



Audience Question
Q: Suppose you have a huge project, half a million lines of code, with no units tests.  Where do you start?
A: Same way you eat an elephant, one bite at a time. Test new code you write. Find a seam and peal off little chunks writing tests as you can.



Audience Question
Q: What tools can be used to measure Code Coverage in Delphi?
A: AQTime Pro - http://smartbear.com/products/qa-tools/application-performance-profiling/features/code-coverage-analysis/



Audience Question
Q: Do you see anything that be improved in RAD Studio and its frameworks to encourage easier testing, i.e. less "RADitis"?
A: Write you model first, form last. Test your business logic.



Audience Question
Q: You mentioned that logic (if clauses) should not be incorporated in tests. Then how to test login?
A: Write one test for one side and another for the other side (one for true, one for false).

5 комментариев:

  1. ОСОБЕННО мне понравилось ВОТ ЧТО:
    Q: You mentioned that logic (if clauses) should not be incorporated in tests. Then how to test login?
    A: Write one test for one side and another for the other side (one for true, one for false).

    ОтветитьУдалить
  2. И вот что:
    "Write you model first, form last. Test your business logic."

    Я ОБ ЭТОМ - ТОЖЕ ТВЕРЖУ. Тестируйте бизнес-логику. А только ПОТОМ - GUI.

    ОтветитьУдалить
  3. И ещё:
    "Audience Question
    Q: How to do test on private procedure
    A: Test the public procedure that calls the private."

    Об этом Тепляков пишет. Я не раз приводил ссылки на него.

    ОтветитьУдалить
  4. А я выкрутился таким образом.
    Класс который необходимо тестировать.
    FDiscountSystem: TDiscountSystem;
    В нём есть приватная процедура
    DestroyDSItems;
    Далее делаем хелпер класс, и в ней пишем процедуру которую будем тестировать:
    TDiscountSystemHelper = class helper for TDiscountSystem
    procedure GetDestroyDSItemsInHelper;
    end;

    procedure TDiscountSystemHelper.GetDestroyDSItemsInHelper;
    var
    MethodPtr: procedure of object;
    begin
    MethodPtr := Self.DestroyDSItems;
    MethodPtr;
    end;

    Собственно сам тест:
    procedure TestTDiscountSystem.TestDestroyDSItems;
    begin
    FDiscountSystem.GetDestroyDSItemsInHelper;
    CheckTrue(FDiscountSystem.CountItems=0, 'Мы уничтожаем все объекты и обнуляем массив');
    end;

    ОтветитьУдалить
  5. Подскажите плз как вставлять в комментариях отформатированный код.

    ОтветитьУдалить