软件测试验收方法_验收测试是美丽的魔术。 这就是它可以改善您的生活的方法。...
軟件測試驗收方法
by Todd Chaffee
托德·查菲(Todd Chaffee)
驗收測試是美麗的魔術。 這就是它可以改善您的生活的方法。 (Acceptance testing is beautiful magic. Here’s how it can improve your life.)
More accurately, automated acceptance testing in the browser is beautiful magic.
更精確地, 瀏覽器中的自動驗收測試是美麗的魔術。
Actually, what I really want to say is that automated acceptance testing might lead to discussing the superb finish of your favorite Pinot Noir with your friends over dinner. I promise this will all make sense by the end of this short article.
實際上,我真正想說的是,自動驗收測試可能會導致您在晚餐時與您的朋友討論您最喜歡的黑比諾葡萄酒的絕妙完成。 我保證在這篇簡短的文章結束時,所有這些都將是有意義的。
Back to beautiful magic.
回到美麗的魔法 。
關于自動驗收測試的一些知識 (A bit about automated acceptance testing)
Every programmer loves automated browser testing when they first see it. I have seen jaded programmers, not easy to impress, who have laughed with joy the first time they see it. I’ll admit I laughed the first time. When you start the tests, your browser will open up and then, without doing anything else, it looks like someone is clicking around and doing stuff.
每個程序員在第一次看到自動瀏覽器測試時都喜歡自動測試。 我見過那些疲憊不堪的程序員,他們不容易留下深刻的印象,他們在第一次看到它時就高興地笑了。 我承認我是第一次笑。 當您開始測試時,您的瀏覽器將打開,然后無需進行任何其他操作,就好像有人在四處閑逛并在做任何事情。
It’s so creepy or fun or fascinating that Chrome feels the need to pop up a warning at the top of the browser: “Chrome is being controlled by automated test software.” I suppose this is to clarify that it’s not ghosts or robots? Let’s call it robots anyway. But no matter how cool it looks at first (even if you’re not impressed with my animated GIF), that’s not even the kind of beautiful magic I am talking about.
Chrome令人毛骨悚然,有趣或令人著迷,以至于Chrome覺得有必要在瀏覽器頂部彈出警告:“ Chrome正在由自動測試軟件控制。” 我想這是為了澄清這不是鬼魂還是機器人? 我們還是稱它為機器人。 但是,不管一開始看起來多么酷(即使您對我的動畫GIF都不滿意),這也不是我所談論的那種美麗的魔術。
As a lifelong programmer, I mostly care about the beautiful magic that makes us better at our jobs. Before I try to sell you on the benefits of automated acceptance testing, let’s quickly put it in context. There are lots of types of testing when it comes to software. One classic way to categorize testing is by how much of the software the tests cover:
作為一生的程序員,我主要關心使我們在工作中變得更好的美麗魔力。 在嘗試向您出售自動化驗收測試的好處之前,讓我們快速介紹一下相關內容。 關于軟件,有很多測試類型。 對測試進行分類的一種經典方法是通過測試涵蓋多少軟件:
Unit testing — tests the smallest possible unit of source code, typically a function or method
單元測試 -測試源代碼的最小可能單元,通常是函數或方法
Integration testing — builds on unit testing by checking how well units work together when they call each other
集成測試 -通過檢查單元之間相互協作的良好程度,在單元測試的基礎上進行構建
Acceptance testing — tests that EVERYTHING works from a user perspective
驗收測試 -從用戶角度測試一切正常
You can do acceptance testing the hard way. First, the programmers click through the entire website, going through manual tests, dozens or hundreds of times. Then the client — who’s paying you — goes through the same painful and time-consuming exercise (and surely misses things). Which leads us from beautiful magic into a mystery:
您可以用困難的方式進行驗收測試。 首先,程序員點擊整個網站,進行數十次或數百次手動測試。 然后,向您付款的客戶-經歷了同樣痛苦而費時的練習(肯定錯過了事情)。 這使我們從美麗的魔法變成了一個謎:
Why are people, who are paid to automate things, manually doing something over and over again that can be done far faster by a robot?
為什么有人付錢使他們自動化,卻又一次又一次地手動做一些可以用機器人更快完成的事情?
I won’t attempt to solve that mystery. Instead, I want to tell you a short story about all the kinds of beautiful magic automated acceptance testing can bring into your programming life.
我不會嘗試解決這個謎。 相反,我想告訴您一個簡短的故事,內容涉及可以帶入您的編程生活中的各種精美的魔術自動驗收測試。
通過自動驗收測試使freeCodeCamp更好 (Making freeCodeCamp better with automated acceptance testing)
The Beta version of freeCodeCamp has some impressive improvements for people learning how to code. One is a feature that allows students to click a button and verify that their project assignment works. You saw a robot clicking that button in the animated GIF above. The button turns green once all the features are working in the student’s project. It provides value to students, because when they click and then see the green light, they can be confident they are finished with the project.
freeCodeCamp的Beta版對學習編碼的人們進行了一些令人印象深刻的改進。 一種功能是允許學生單擊按鈕并驗證他們的項目分配是否有效。 您在上面的動畫GIF中看到一個機器人單擊了該按鈕。 一旦學生項目中的所有功能都起作用,該按鈕將變為綠色。 它為學生提供了價值,因為當他們單擊并看到綠燈時,他們可以確信自己已完成項目。
Thanks to the hard work of Peter Weinberg, Anis Nouira, Tracey Bushman Christian Paul, Sean Smith, Andre Alonzo, and others, we have this feature for 15 of the project assignments on the beta version of freeCodeCamp. You can see an example of each project over at CodePen, and even run the tests manually yourself.
由于Peter Weinberg , Anis Nouira , Tracey Bushman Christian Paul , Sean Smith , Andre Alonzo和其他人的辛勤工作,我們在freeCodeCamp的beta版中為15個項目分配了此功能。 您可以在CodePen上查看每個項目的示例,甚至可以自己手動運行測試。
This feature is a type of test, but it’s not the kind of testing we are talking about. So let’s continue to call it a feature to avoid confusion. The feature has a web UI that students use just like any feature on any other web site. Someone had to code that UI. And for each assigned student project, someone had to write a separate set of code that describes the unique features of that project. You can see all the code over at the GitHub repo (please consider volunteering if you would like to help us improve this feature).
此功能是一種測試,但不是我們正在談論的那種測試。 因此,讓我們繼續稱其為功能以避免混淆。 該功能具有一個Web UI,學生可以像使用其他任何網站上的任何功能一樣使用它。 有人必須編寫該UI。 對于每個分配的學生項目,都必須編寫一組單獨的代碼來描述該項目的獨特功能。 您可以在GitHub存儲庫中查看所有代碼(如果您想幫助我們改進此功能,請考慮自愿)。
Each contributor also has the responsibility of making sure this feature works for the hundreds of thousands of eventual freeCodeCamp students that will use it. It is a production feature that lives on the web like any other website feature.
每個貢獻者還負責確保此功能適用于成千上萬將要使用它的freeCodeCamp學生。 它是一項生產功能,與其他任何網站功能一樣,都存在于網絡中。
Savvy programmers will have already figured out where I’m heading: writing automated acceptance tests for this feature. And yes, this feature is a test, so we are testing the tests. Does this sound like too much testing? It’s not. As long as an end user somewhere is going to use your feature on the web, there is good reason to automate the testing of that feature. Even if the feature itself is a sort of test. Enough meta, let’s move on.
精明的程序員已經弄清楚了我要去的方向:為此功能編寫自動驗收測試。 是的,此功能是一項測試,因此我們正在測試這些測試。 這聽起來像是過多的測試 ? 不是。 只要某個地方的最終用戶要在網絡上使用您的功能,就有充分的理由自動進行該功能的測試。 即使功能本身是一種測試。 足夠的元數據,讓我們繼續前進。
When I joined the project that provides this feature, I was asked along with other volunteers to fix some bugs students had discovered.
當我加入提供此功能的項目時,我和其他志愿者一起被要求修復學生發現的一些錯誤。
I happily reproduced the first issue and started coding. Pretty quickly I fixed my first bug, and then it came time to test my solution. Argh, the pain! The hair being torn out in frustration! The absurd amount of time it took me! This was my process:
我愉快地復制了第一期并開始編碼。 很快,我修復了我的第一個錯誤,然后是時候測試我的解決方案了。 啊,痛苦! 頭發被挫敗了! 我花了荒謬的時間! 這是我的過程:
And this is the worst part: go back to step 2 and repeat for each of the other fourteen CodePen sample projects!
這是最糟糕的部分: 回到步驟2,對其他14個CodePen示例項目中的每一個重復!
If, at any point, you find and fix another problem with your code, you need to repeat the entire thing.
如果您在任何時候發現并解決了代碼的另一個問題,則需要重復整個過程。
It took me about ten minutes to reproduce and fix my first issue. And almost an hour of boring clicking to test my changes and make sure my fix did not break something else. I knew this couldn’t continue. I didn’t want it to continue.
我花了大約十分鐘的時間來重制和修復我的第一期雜志。 無聊的點擊將近一個小時 ,以測試我的更改并確保我的修復程序不會破壞其他功能。 我知道這將無法繼續。 我不想繼續下去。
It wasn’t scalable, and we are hoping to add more camper projects and to eventually support more frameworks like Angular. We also wanted to make sure the feature works on all modern browsers and operating systems — and I had only tested it on Linux with Chrome. Did I need to recruit another volunteer for an hour of their time to test on Mac? What about Windows?
它不是可擴展的,我們希望添加更多的露營項目,并最終支持更多的框架,例如Angular。 我們還想確保該功能在所有現代瀏覽器和操作系統上都能正常工作-我只在Linux和Chrome上對其進行過測試。 我是否需要招募一個小時的志愿者來在Mac上進行測試? Windows呢?
It felt like the testing process was going to make the project a bad experience for volunteers. It was already a bad experience for me. Almost no time would be spent doing the actual fun part: the programming. So I returned to the fun part, and wrote a program to automate the acceptance testing using Selenium.
感覺測試過程將使該項目成為志愿者的糟糕經歷。 對我來說已經是很糟糕的經歷。 幾乎沒有時間會花在做真正有趣的部分上:編程。 因此,我回到了有趣的部分,并編寫了一個程序來使用Selenium自動化驗收測試。
Here is the test process now that we have automated it with Selenium:
現在,我們已經使用Selenium自動化了測試過程:
npm testThat’s it. You can immediately return to programming (or whatever it is you enjoy more than the grunt work of manually testing) and come back four minutes later to see if all the tests passed. An hour-long manual process reduced to four minutes. Robots can be fast.
而已。 您可以立即返回編程(或者您可以享受比手動測試更艱巨的工作),并在四分鐘后回來查看所有測試是否通過。 一個小時的手動過程減少到四分鐘。 機器人可以很快。
美麗的魔法 (The beautiful magic)
The number one thing I get out of automated acceptance testing is more time to do the things I really enjoy. Since it might not be obvious from my story, here’s a list of some of the other beautiful magic you can get out of automating your acceptance tests.
我從自動化驗收測試中學到的第一件事就是花更多的時間去做我真正喜歡的事情 。 由于從我的故事中可能并不明顯,因此,這里列出了一些其他一些神奇的魔術,您可以從自動化驗收測試中獲得這些魔術。
It’s repeatable. A robot never forget any of the tests.
可重復的。 機器人永遠不會 忘記任何測試。
GitHub allows you to run the tests automatically on a continuous integration server when you create a pull request. You can make sure every PR passes the tests before it is merged. Here is a link to the output of the Travis CI tests for one of our PRs.
創建拉取請求時,GitHub允許您在連續集成服務器上自動運行測試。 您可以確保每個PR在合并之前都通過測試。 這是我們PR之一的Travis CI測試輸出的鏈接 。
You can cover far more configurations. A human tester will usually have access to one or two operating systems and a couple of browsers (at most). Maybe a couple of different mobile phones. With automated testing, you can run your tests on hundreds of combinations of operating systems, mobile phones, and browser versions.
您可以涵蓋更多配置。 人工測試人員通常可以訪問一個或兩個操作系統以及兩個瀏覽器(最多)。 也許有幾個不同的手機。 借助自動化測試,您可以在數百種操作系統,移動電話和瀏覽器版本的組合上運行測試。
One final benefit. Let’s imagine a client calls you on a Friday night as you are about to sit down to dinner with friends. You make the mistake of answering the call because it’s one of your better clients. They desperately need one line of code changed to fix something minor for a huge weekend sale. It’s an easy fix so you bang it out in five minutes. Now you have two choices (I’m not including the unwise “choice” of not testing your change):
最后的好處。 假設有一個客戶在星期五晚上與您坐下來共進晚餐時打電話給您。 您接聽電話是錯誤的,因為它是您更好的客戶之一。 他們迫切需要更改一行代碼,以解決大型周末銷售中的一些小問題。 這是一個簡單的解決方法,因此您可以在五分鐘之內將其完成。 現在,您有兩個選擇(我不包括不測試更改的不明智的“選擇”):
Do you go through at least an hour-long process of manually testing every feature on the website to make sure your fix did not break anything? In your rush not to leave your friends waiting, what tests will you miss?
您是否經歷了至少一個小時的手動測試網站上所有功能的過程,以確保您的修復程序沒有中斷任何事情? 急于不讓您的朋友等待,您會錯過哪些測試?
Or do you type npm test and let a robot take over so you can return to the company of your friends, who have just opened a bottle of your favorite Pinot Noir? One hundred percent confident you haven’t broken anything and your weekend of fun can begin (while your client’s big sale makes them buckets of money).
還是您鍵入npm test并讓機器人接管,以便您可以回到朋友的陪伴下,他們剛打開了一瓶您最喜歡的黑比諾葡萄酒 ? 百分之一百的信心,您什么都沒做,周末的樂趣就可以開始(而客戶的大筆交易使他們賺了很多錢)。
If that’s not beautiful magic — I did promise and deliver wine — then you might never be convinced to give automated acceptance testing a try.
如果那不是美麗的魔力-我確實保證并交付了葡萄酒-那么您可能永遠不會說服您嘗試自動驗收測試。
If you’d like to learn more about how you can make your automated tests reliable and fast, check out my article on Reliable Selenium NodeJS Tests. Wine not included.
如果您想了解更多有關如何使自動測試可靠且快速的信息,請查看我有關Reliable Selenium NodeJS Tests的文章。 不包括葡萄酒。
Did you like this article? If so, give me some claps so more people see it. Thanks!
你喜歡這篇文章嗎? 如果是這樣,給我鼓掌,讓更多的人看到它。 謝謝!
翻譯自: https://www.freecodecamp.org/news/acceptance-testing-is-beautiful-magic-heres-how-it-can-improve-your-life-41759775d19d/
軟件測試驗收方法
總結
以上是生活随笔為你收集整理的软件测试验收方法_验收测试是美丽的魔术。 这就是它可以改善您的生活的方法。...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java关闭一个窗口打开另一个_推开中式
- 下一篇: 关注 Imagine Cup 2010,