Archive for the ‘Hrvatski (Croatian)’ Category
Watir, Ruby, objekti i varijable
Živim od testiranja web aplikacija. Služim se Rubyjem i Watirom za automatiziranje testova funkcionalnosti. Moje skripte su narasle, pa sam napravio mali framework (ne znam kako ovo pametno prevesti) kako bi ih pojednostavnio (sav kod u ovom članku je pojednostavljen i neisproban).
Klasa Page olakšava provjeravanje url-a i tekst(ov)a stranice.
class Page
def initialize(ie, url, texts)
@ie, @url, @texts = ie, url, texts
end
def check
@texts.each do |text|
assert(@ie.contains_text(text))
end
assert_equal(@url, @ie.url)
end
end
“Pogledaj element” stranica u aplikaciji koju testiram ima tekst (breadcrumb – opet ne znam kako bi ovo smisleno preveo) {vrsta_elementa} > View (primjer: File > View).”
Nakon što je element dodan/promijenjen, na toj stranici se nalazi i tekst {vrsta_elementa} {akcija}. (primjer: File added.).
Klasa File, naravno, testira datoteke.
class File
def initialize
@page_view = Page.new(
"app.com/view.aspx",
["File > View"])
@page_view_after_add = Page.new(
"app.com/view.aspx",
["File > View", "File added."])
@page_view_after_edit = Page.new(
"app.com/view.aspx",
["File > View", "File edited."])
end
def add
# add file
@page_view_after_add.check
end
def edit
# edit file
@page_view_after_edit.check
end
def view
# go to file
@page_view.check
end
end
I sve baš lijepo radi. Sve što trebam napisati je ovo.
file = File.new file.add file.edit file.view
Postoje tri objekta. Jedan za svaku (@page_view…) varijablu. “id” u “Page:{id}” je različit za svaku varijablu.
#<Page:0x2b5ac28 @url="app.com/view.aspx", @texts=["File > View"]>
#<Page:0x2b5ab98 @url="app.com/view.aspx", @texts=["File > View", "File added."]>
#<Page:0x2b5ab08 @url="app.com/view.aspx", @texts=["File > View", "File edited."]>
Ali, dupliciranje me muči.
Želio bi da File#initialize izgleda ovako.
@page_view = @page_view_after_add = @page_view_after_edit = Page.new( "app.com/view.aspx", ["File > View"]) @page_view_after_add.texts < < "File added." @page_view_after_edit.texts << "File edited."
Ali (iznenađenje!), to ne radi. Pa, prilično sam novi u objektno orijentiranom svijetu, pa mi to i nije iznenađenje.
Na ovaj način stvoren je samo jedan Page objekt, i sve tri varijable pokazuju na njega. Bez obzira koju varijablu promijenim, ona promijeni objekt na koji pokazuje. Rezultat je da su sve tri varijable iste. To nije ono što sam želio.
#<Page:0x2820048 @url="app.com/view.aspx", @texts=["File > View", "File added.", "File edited."]>
#<Page:0x2820048 @url="app.com/view.aspx", @texts=["File > View", "File added.", "File edited."]>
#<Page:0x2820048 @url="app.com/view.aspx", @texts=["File > View", "File added.", "File edited."]>
Isprobao sam nekoliko alternativa, ali niti jedna nije uspjela. Za sad mogu živjeti s duplikacijom, ali bi je volio ukloniti iz mojih skripti.
Programer ili tester?
Adam Ulrich piše o tome što rade programeri, a što testeri u Microsoftu, te kako znati jesi li materijal za programera ili testera. Prenosim samo dio:
You are better suited to be an SDE if
- you like to get really deep in one technology space for long stretches
- you don’t stop until you write the perfect algorithm, or the most elegant codeYou are better suited to be an SDET if
- You like system integration type work:
—you take the technology that this team did, make use of it and tie it to this other piece of technology, etc.- You may have been a TA and graded other peoples code, or were the guy in group projects who enjoyed and was good at poking holes in other peoples designs
- You have strong big picture thinking, and are focusing your energy on solving the whole problem.
—You find yourself coming up with “good enough” solutions to problems. Your solutions may or may not be elegant or perfect, but you are happy with it and you’ve moved on to the next part of the problem.
Kako saznati što sve te čudne skraćenice u tekstu znače (SDE, SDET, PM, OM…)? Upiši u Google:
site:microsoft.com SDE
SDE – Software Design Engineer – programer
SDET- Software Design Engineer in Test – tester
Testiranje za programere
O, da, i programeri testiraju. O tome kako da to rade bolje piše The Braidy Tester.
