Skip to main content

Home/ Larvata/ Group items tagged exercises

Rss Feed Group items tagged

crazylion lee

PostgreSQL Exercises - 0 views

  •  
    "Welcome to PostgreSQL Exercises! This site was born when I noticed that there's a load of material out there to help people learn about SQL, but not a great deal to make it easy to learn by doing. PGExercises provides a series of questions and explanations built on a single, simple dataset. It's designed for use as a partner to a good book or Postgres' excellent documentation."
張 旭

Four-Phase Test - 0 views

crazylion lee

I don't understand Python's Asyncio | Armin Ronacher's Thoughts and Writings - 0 views

  •  
    "Recently I started looking into Python's new asyncio module a bit more. The reason for this is that I needed to do something that works better with evented IO and I figured I might give the new hot thing in the Python world a try. Primarily what I learned from this exercise is that I it's a much more complex system than I expected and I am now at the point where I am very confident that I do not know how to use it properly. It's not conceptionally hard to understand and borrows a lot from Twisted, but it has so many elements that play into it that I'm not sure any more how the individual bits and pieces are supposed to go together. Since I'm not clever enough to actually propose anything better I just figured I share my thoughts about what confuses me instead so that others might be able to use that in some capacity to understand it."
張 旭

Ruby on Rails 實戰聖經 | 自動化測試 - 0 views

  • 最小的測試粒度叫做Unit Test單元測試,會對個別的類別和方法測試結果如預期。再大一點的粒度稱作Integration Test整合測試,測試多個元件之間的互動正確。最大的粒度則是Acceptance Test驗收測試,從用戶觀點來測試整個軟體。
  • 單元測試,通常會由開發者自行負責測試,因為只有你自己清楚每個類別和方法的內部結構是怎麼設計的。
  • 哪來的時間做自動化測試呢?這個想法是相當短視和業餘的想法
  • ...18 more annotations...
  • 這其實是一種投資,如果是簡單的程式,也許你手動執行一次就寫對了,但是如果是複雜的程式,往往第一次不會寫對,你會浪費很多時間在檢查到底你寫的程式的正確性,而寫測試就可以大大的節省這些時間。更不用說你明天,下個禮拜或下個月需要再確認其他程式有沒有副作用影響的時候,你有一組測試程式可以大大節省手動檢查的時間。
  • 幾乎每種語言都有一套叫做xUnit測試框架的測試工具
  • 標準流程是 1. (Setup) 設定測試資料 2. (Exercise) 執行要測試的方法 3. (Verify) 檢查結果是否正確 4. (Teardown) 清理還原資料
  • RSpec是一套改良版的xUnit測試框架,非常風行於Rails社群
  • 個別的單元測試應該是獨立不會互相影響的
  • 一個it區塊,就是一個單元測試,裡面的expect方法會進行驗證。
  • RSpec裡,我們又把一個小單元測試叫做example
  • BDD(Behavior-driven development)測試框架,相較於TDD用test思維,測試程式的結果。BDD強調的是用spec思維,描述程式應該有什麼行為。
  • describe和context幫助你組織分類,都是可以任意套疊的。
  • 每個it就是一小段測試,在裡面我們會用expect(…).to來設定期望
  • let可以用來簡化上述的before用法,並且支援lazy evaluation和memoized,也就是有需要才初始,並且不同單元測試之間,只會初始化一次,可以增加測試執行效率
  • let!則會在測試一開始就先初始一次,而不是lazy evaluation。
  • 先列出來預計要寫的測試,或是暫時不要跑的測試
  • specify和example都是it方法的同義字。
  • 進階一點你可以自己寫Matcher
  • RSpec分成數種不同測試,分別是Model測試、Controller測試、View測試、Helper測試、Route和Request測試
  • Rails內建有Fixture功能可以建立假資料,方法是為每個Model使用一份YAML資料。
  • 記得確認每個測試案例之間的測試資料需要清除
1 - 5 of 5
Showing 20 items per page