Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How we test our projects

85a64fb3375926c0be5c75eccf40e853?s=47 Terry
November 18, 2012

How we test our projects

Rubyconf China 2012

85a64fb3375926c0be5c75eccf40e853?s=128

Terry

November 18, 2012
Tweet

Transcript

  1. None
  2. whoami

  3. None
  4. 太檑

  5. Terry

  6. @poshboytl

  7. Co-founder of Pragmatic.ly

  8. None
  9. Creator of Railscasts-china.com

  10. None
  11. Survey

  12. How many people write tests?

  13. How many people use RSpec?

  14. Tools we use

  15. None
  16. I love RSpec!

  17. None
  18. None
  19. Bad boy!

  20. None
  21. x.should == y

  22. None
  23. None
  24. Straightforward!

  25. asset_equal y, x

  26. None
  27. None
  28. This is just right!

  29. Pillow War!

  30. Peace! Choose what you like!

  31. Try it, instead of following anybody.

  32. Syntax

  33. Syntax Sugar

  34. Syntax Sugar DSL

  35. Is syntax important?

  36. None
  37. None
  38. None
  39. Syntax is important, that’s the most important reason why we

    love Ruby! It also can be the reason we love RSepc!
  40. Syntax is important, that’s the most important reason why we

    love Ruby! It also can be the reason we love RSepc! Terry Tai
  41. Let’s talk about RSpec!

  42. Our practices

  43. None
  44. None
  45. None
  46. None
  47. None
  48. None
  49. None
  50. None
  51. None
  52. None
  53. None
  54. None
  55. None
  56. None
  57. None
  58. None
  59. Setup phase contains two parts use ‘let’ to initialize data

    ‘before’ block to do some actions
  60. None
  61. None
  62. None
  63. None
  64. None
  65. None
  66. None
  67. None
  68. Why straightforward is important for us?

  69. None
  70. None
  71. None
  72. The sugar we don’t like very much

  73. None
  74. None
  75. None
  76. RSpec done

  77. None
  78. Problem of Fixtures

  79. Hard to read Hard to write Hard to maintain

  80. None
  81. None
  82. What’s the password?

  83. What’s the password?

  84. What’s the password? Add new records?

  85. Fixtures separate the data and the tests

  86. None
  87. None
  88. Bullshit!

  89. None
  90. What’s the advantage of fixtures?

  91. It’s really fast!!

  92. Some practices for Factory Girl

  93. None
  94. None
  95. None
  96. None
  97. None
  98. None
  99. None
  100. None
  101. Random data is a advantage of factory to fixtures

  102. None
  103. Update: If you wanna use LoremIpsum class still need the

    gems like forgery or lorem-ipsum.
  104. None
  105. None
  106. None
  107. None
  108. None
  109. None
  110. How we run tests?

  111. You might see this

  112. But...... I really don’t use it

  113. Tell you a secret

  114. I run my tests manually

  115. Why?

  116. probably, I type :w so frequently and quickly. LOL

  117. probably, I type :w so frequently and quickly. LOL

  118. None
  119. None
  120. None
  121. Your APM should be high

  122. Slayers Boxer Your APM should be high

  123. Manually run ‘bundle exec rspec spec’ ?

  124. No. It depends.

  125. None
  126. None
  127. bundle exec rspec spec ruby -S rspec spec

  128. Bundler still need time to load

  129. When I can not use ‘bundle exec’ ?

  130. None
  131. None
  132. no spec_helper

  133. Two ways to run tests?

  134. None
  135. None
  136. ruby -S rspec spec ?

  137. bundle exec rspec spec ? ruby -S rspec spec ?

  138. by Gray Bernhardt

  139. None
  140. About integration test

  141. RSpec + Capybara(webkit)

  142. Poltergeist looks nice will give it a try

  143. I don’t love it so far Also don’t hate it

    Still keep looking
  144. Stub as little as possible only do for Current time

    HTTP visiting ...
  145. VCR

  146. None
  147. Use different fixture data in integration and unit tests

  148. Integration tests are not for driving development

  149. No mock or stub means slow You can use a

    CI server run it for you
  150. if project.open_source?

  151. A hosted continuous integration service for the open source community.

  152. else

  153. None
  154. integrity • light weight • It built by ruby (Means

    you can hack!!!) • Works pretty well with git • Hook and API is weak
  155. None
  156. Hudson and Jenkins • They built by JAVA • Heavy

    weight and powerful • a lot of plugins(git, github, emails, hipchat...) • Have nice API
  157. We really did some interesting things with Hudson by HUBOT

  158. http://terrytai.com/

  159. JS tests

  160. None
  161. None
  162. jasminerice gem for work with Rails asset pipeline

  163. jasmine-sinon

  164. None
  165. By Ian: https://gist.github.com/4059889

  166. None
  167. None
  168. None
  169. None
  170. None
  171. Look at me, Terry. It’s not a JS conf, ok?

  172. I’d better stop here

  173. Oh, BTW

  174. DHH is the hero in my heart

  175. Thank you!