软件测试验收方法_验收测试是美丽的魔术。 这就是它可以改善您的生活的方法。...
軟件測(cè)試驗(yàn)收方法
by Todd Chaffee
托德·查菲(Todd Chaffee)
驗(yàn)收測(cè)試是美麗的魔術(shù)。 這就是它可以改善您的生活的方法。 (Acceptance testing is beautiful magic. Here’s how it can improve your life.)
More accurately, automated acceptance testing in the browser is beautiful magic.
更精確地, 瀏覽器中的自動(dòng)驗(yàn)收測(cè)試是美麗的魔術(shù)。
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.
實(shí)際上,我真正想說的是,自動(dòng)驗(yàn)收測(cè)試可能會(huì)導(dǎo)致您在晚餐時(shí)與您的朋友討論您最喜歡的黑比諾葡萄酒的絕妙完成。 我保證在這篇簡(jiǎn)短的文章結(jié)束時(shí),所有這些都將是有意義的。
Back to beautiful magic.
回到美麗的魔法 。
關(guān)于自動(dòng)驗(yàn)收測(cè)試的一些知識(shí) (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.
每個(gè)程序員在第一次看到自動(dòng)瀏覽器測(cè)試時(shí)都喜歡自動(dòng)測(cè)試。 我見過那些疲憊不堪的程序員,他們不容易留下深刻的印象,他們?cè)诘谝淮慰吹剿鼤r(shí)就高興地笑了。 我承認(rèn)我是第一次笑。 當(dāng)您開始測(cè)試時(shí),您的瀏覽器將打開,然后無需進(jìn)行任何其他操作,就好像有人在四處閑逛并在做任何事情。
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正在由自動(dòng)測(cè)試軟件控制。” 我想這是為了澄清這不是鬼魂還是機(jī)器人? 我們還是稱它為機(jī)器人。 但是,不管一開始看起來多么酷(即使您對(duì)我的動(dòng)畫GIF都不滿意),這也不是我所談?wù)摰哪欠N美麗的魔術(shù)。
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:
作為一生的程序員,我主要關(guān)心使我們?cè)诠ぷ髦凶兊酶玫拿利惸ЯΑ?在嘗試向您出售自動(dòng)化驗(yàn)收測(cè)試的好處之前,讓我們快速介紹一下相關(guān)內(nèi)容。 關(guān)于軟件,有很多測(cè)試類型。 對(duì)測(cè)試進(jìn)行分類的一種經(jīng)典方法是通過測(cè)試涵蓋多少軟件:
Unit testing — tests the smallest possible unit of source code, typically a function or method
單元測(cè)試 -測(cè)試源代碼的最小可能單元,通常是函數(shù)或方法
Integration testing — builds on unit testing by checking how well units work together when they call each other
集成測(cè)試 -通過檢查單元之間相互協(xié)作的良好程度,在單元測(cè)試的基礎(chǔ)上進(jìn)行構(gòu)建
Acceptance testing — tests that EVERYTHING works from a user perspective
驗(yàn)收測(cè)試 -從用戶角度測(cè)試一切正常
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:
您可以用困難的方式進(jìn)行驗(yàn)收測(cè)試。 首先,程序員點(diǎn)擊整個(gè)網(wǎng)站,進(jìn)行數(shù)十次或數(shù)百次手動(dòng)測(cè)試。 然后,向您付款的客戶-經(jīng)歷了同樣痛苦而費(fèi)時(shí)的練習(xí)(肯定錯(cuò)過了事情)。 這使我們從美麗的魔法變成了一個(gè)謎:
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?
為什么有人付錢使他們自動(dòng)化,卻又一次又一次地手動(dòng)做一些可以用機(jī)器人更快完成的事情?
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.
我不會(huì)嘗試解決這個(gè)謎。 相反,我想告訴您一個(gè)簡(jiǎn)短的故事,內(nèi)容涉及可以帶入您的編程生活中的各種精美的魔術(shù)自動(dòng)驗(yàn)收測(cè)試。
通過自動(dòng)驗(yàn)收測(cè)試使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版對(duì)學(xué)習(xí)編碼的人們進(jìn)行了一些令人印象深刻的改進(jìn)。 一種功能是允許學(xué)生單擊按鈕并驗(yàn)證他們的項(xiàng)目分配是否有效。 您在上面的動(dòng)畫GIF中看到一個(gè)機(jī)器人單擊了該按鈕。 一旦學(xué)生項(xiàng)目中的所有功能都起作用,該按鈕將變?yōu)榫G色。 它為學(xué)生提供了價(jià)值,因?yàn)楫?dāng)他們單擊并看到綠燈時(shí),他們可以確信自己已完成項(xiàng)目。
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和其他人的辛勤工作,我們?cè)趂reeCodeCamp的beta版中為15個(gè)項(xiàng)目分配了此功能。 您可以在CodePen上查看每個(gè)項(xiàng)目的示例,甚至可以自己手動(dòng)運(yùn)行測(cè)試。
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).
此功能是一種測(cè)試,但不是我們正在談?wù)摰哪欠N測(cè)試。 因此,讓我們繼續(xù)稱其為功能以避免混淆。 該功能具有一個(gè)Web UI,學(xué)生可以像使用其他任何網(wǎng)站上的任何功能一樣使用它。 有人必須編寫該UI。 對(duì)于每個(gè)分配的學(xué)生項(xiàng)目,都必須編寫一組單獨(dú)的代碼來描述該項(xiàng)目的獨(dú)特功能。 您可以在GitHub存儲(chǔ)庫中查看所有代碼(如果您想幫助我們改進(jìn)此功能,請(qǐng)考慮自愿)。
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.
每個(gè)貢獻(xiàn)者還負(fù)責(zé)確保此功能適用于成千上萬將要使用它的freeCodeCamp學(xué)生。 它是一項(xiàng)生產(chǎn)功能,與其他任何網(wǎng)站功能一樣,都存在于網(wǎng)絡(luò)中。
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.
精明的程序員已經(jīng)弄清楚了我要去的方向:為此功能編寫自動(dòng)驗(yàn)收測(cè)試。 是的,此功能是一項(xiàng)測(cè)試,因此我們正在測(cè)試這些測(cè)試。 這聽起來像是過多的測(cè)試 ? 不是。 只要某個(gè)地方的最終用戶要在網(wǎng)絡(luò)上使用您的功能,就有充分的理由自動(dòng)進(jìn)行該功能的測(cè)試。 即使功能本身是一種測(cè)試。 足夠的元數(shù)據(jù),讓我們繼續(xù)前進(jìn)。
When I joined the project that provides this feature, I was asked along with other volunteers to fix some bugs students had discovered.
當(dāng)我加入提供此功能的項(xiàng)目時(shí),我和其他志愿者一起被要求修復(fù)學(xué)生發(fā)現(xiàn)的一些錯(cuò)誤。
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:
我愉快地復(fù)制了第一期并開始編碼。 很快,我修復(fù)了我的第一個(gè)錯(cuò)誤,然后是時(shí)候測(cè)試我的解決方案了。 啊,痛苦! 頭發(fā)被挫敗了! 我花了荒謬的時(shí)間! 這是我的過程:
And this is the worst part: go back to step 2 and repeat for each of the other fourteen CodePen sample projects!
這是最糟糕的部分: 回到步驟2,對(duì)其他14個(gè)CodePen示例項(xiàng)目中的每一個(gè)重復(fù)!
If, at any point, you find and fix another problem with your code, you need to repeat the entire thing.
如果您在任何時(shí)候發(fā)現(xiàn)并解決了代碼的另一個(gè)問題,則需要重復(fù)整個(gè)過程。
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.
我花了大約十分鐘的時(shí)間來重制和修復(fù)我的第一期雜志。 無聊的點(diǎn)擊將近一個(gè)小時(shí) ,以測(cè)試我的更改并確保我的修復(fù)程序不會(huì)破壞其他功能。 我知道這將無法繼續(xù)。 我不想繼續(xù)下去。
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?
它不是可擴(kuò)展的,我們希望添加更多的露營項(xiàng)目,并最終支持更多的框架,例如Angular。 我們還想確保該功能在所有現(xiàn)代瀏覽器和操作系統(tǒng)上都能正常工作-我只在Linux和Chrome上對(duì)其進(jìn)行過測(cè)試。 我是否需要招募一個(gè)小時(shí)的志愿者來在Mac上進(jìn)行測(cè)試? 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.
感覺測(cè)試過程將使該項(xiàng)目成為志愿者的糟糕經(jīng)歷。 對(duì)我來說已經(jīng)是很糟糕的經(jīng)歷。 幾乎沒有時(shí)間會(huì)花在做真正有趣的部分上:編程。 因此,我回到了有趣的部分,并編寫了一個(gè)程序來使用Selenium自動(dòng)化驗(yàn)收測(cè)試。
Here is the test process now that we have automated it with Selenium:
現(xiàn)在,我們已經(jīng)使用Selenium自動(dòng)化了測(cè)試過程:
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.
而已。 您可以立即返回編程(或者您可以享受比手動(dòng)測(cè)試更艱巨的工作),并在四分鐘后回來查看所有測(cè)試是否通過。 一個(gè)小時(shí)的手動(dòng)過程減少到四分鐘。 機(jī)器人可以很快。
美麗的魔法 (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.
我從自動(dòng)化驗(yàn)收測(cè)試中學(xué)到的第一件事就是花更多的時(shí)間去做我真正喜歡的事情 。 由于從我的故事中可能并不明顯,因此,這里列出了一些其他一些神奇的魔術(shù),您可以從自動(dòng)化驗(yàn)收測(cè)試中獲得這些魔術(shù)。
It’s repeatable. A robot never forget any of the tests.
可重復(fù)的。 機(jī)器人永遠(yuǎn)不會(huì) 忘記任何測(cè)試。
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.
創(chuàng)建拉取請(qǐng)求時(shí),GitHub允許您在連續(xù)集成服務(wù)器上自動(dòng)運(yùn)行測(cè)試。 您可以確保每個(gè)PR在合并之前都通過測(cè)試。 這是我們PR之一的Travis CI測(cè)試輸出的鏈接 。
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.
您可以涵蓋更多配置。 人工測(cè)試人員通常可以訪問一個(gè)或兩個(gè)操作系統(tǒng)以及兩個(gè)瀏覽器(最多)。 也許有幾個(gè)不同的手機(jī)。 借助自動(dòng)化測(cè)試,您可以在數(shù)百種操作系統(tǒng),移動(dòng)電話和瀏覽器版本的組合上運(yùn)行測(cè)試。
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):
最后的好處。 假設(shè)有一個(gè)客戶在星期五晚上與您坐下來共進(jìn)晚餐時(shí)打電話給您。 您接聽電話是錯(cuò)誤的,因?yàn)樗悄玫目蛻糁弧?他們迫切需要更改一行代碼,以解決大型周末銷售中的一些小問題。 這是一個(gè)簡(jiǎn)單的解決方法,因此您可以在五分鐘之內(nèi)將其完成。 現(xiàn)在,您有兩個(gè)選擇(我不包括不測(cè)試更改的不明智的“選擇”):
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?
您是否經(jīng)歷了至少一個(gè)小時(shí)的手動(dòng)測(cè)試網(wǎng)站上所有功能的過程,以確保您的修復(fù)程序沒有中斷任何事情? 急于不讓您的朋友等待,您會(huì)錯(cuò)過哪些測(cè)試?
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并讓機(jī)器人接管,以便您可以回到朋友的陪伴下,他們剛打開了一瓶您最喜歡的黑比諾葡萄酒 ? 百分之一百的信心,您什么都沒做,周末的樂趣就可以開始(而客戶的大筆交易使他們賺了很多錢)。
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.
如果那不是美麗的魔力-我確實(shí)保證并交付了葡萄酒-那么您可能永遠(yuǎn)不會(huì)說服您嘗試自動(dòng)驗(yàn)收測(cè)試。
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.
如果您想了解更多有關(guān)如何使自動(dòng)測(cè)試可靠且快速的信息,請(qǐng)查看我有關(guān)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/
軟件測(cè)試驗(yàn)收方法
總結(jié)
以上是生活随笔為你收集整理的软件测试验收方法_验收测试是美丽的魔术。 这就是它可以改善您的生活的方法。...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java关闭一个窗口打开另一个_推开中式
- 下一篇: 关注 Imagine Cup 2010,