O documento discute a importância de testes no desenvolvimento de software. Resume-se que testes permitem refatorar código com segurança e encontrar problemas de forma antecipada.
11. public WaveformDisplay(Composite parent, int style) {
super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL);
_parent = parent;
_hbar = getHorizontalBar();
_hbar.setMinimum(0);
_hbar.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent se) {
widgetSelected(se);
}
public void widgetSelected(SelectionEvent se) {
updateXStart();
for (Waveform w : _wf) {
Vou escrever testes, mas o
w.redraw(); código está muito acoplado.
}
_timeBar.redraw(); Para isso precisarei
} refatorar, mas não tenho
});
_hbar.setVisible(false); segurança para refatorar se
_vbar = getVerticalBar();
eu não tenho testes.
_vbar.setMinimum(0);
_vbar.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent se) {
widgetSelected(se);
}
public void widgetSelected(SelectionEvent se) {
updateYStart();
for (Waveform w : _wf) {
w.redraw();
}
}
Codigo muito feio não dava
});
_vbar.setVisible(false); segurança
_wf = new ArrayList<Waveform>(); E se eu quebrar?
_sampleArrays = new ArrayList<SampleArray>();
setBackground(AcmusGraphics.WHITE); E ainda multiplicamos por 5
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
a cobertura. de 0.3% para
gl.marginWidth = 0;
gl.horizontalSpacing = 0;
1.5%
gl.verticalSpacing = 1;
setLayout(gl);
_timeBar = new TimeBar(this);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.heightHint = _xBarHeight;
_timeBar.setLayoutData(gridData);
amplitude();
}
12. public WaveformDisplay(Composite parent, int style) {
super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL);
_parent = parent;
_hbar = getHorizontalBar();
_hbar.setMinimum(0);
_hbar.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent se) {
widgetSelected(se);
}
public void widgetSelected(SelectionEvent se) {
updateXStart();
for (Waveform w : _wf) {
Vou escrever testes, mas o
w.redraw(); código está muito acoplado.
}
_timeBar.redraw(); Para isso precisarei
} refatorar, mas não tenho
});
_hbar.setVisible(false); segurança para refatorar se
_vbar = getVerticalBar();
eu não tenho testes.
_vbar.setMinimum(0);
_vbar.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent se) {
widgetSelected(se);
}
public void widgetSelected(SelectionEvent se) {
updateYStart();
for (Waveform w : _wf) {
w.redraw();
}
}
Codigo muito feio não dava
});
_vbar.setVisible(false); segurança
_wf = new ArrayList<Waveform>(); E se eu quebrar?
_sampleArrays = new ArrayList<SampleArray>();
setBackground(AcmusGraphics.WHITE); E ainda multiplicamos por 5
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
a cobertura. de 0.3% para
gl.marginWidth = 0;
gl.horizontalSpacing = 0;
1.5%
gl.verticalSpacing = 1;
setLayout(gl);
_timeBar = new TimeBar(this);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.heightHint = _xBarHeight;
_timeBar.setLayoutData(gridData);
amplitude();
}
17. class TestaCalculadora
def test_soma
Calculadora.soma 1
Calculadora.soma 2
if Calculadora.total == 3
puts "teste passando"
else
puts "teste falhou"
end
end
end
18. TestUnit
class TestaCalculadora class TestaCalculadora < Test::Unit::TestCase
def test_soma
Calculadora.soma 1
def test_soma
Calculadora.soma 2 Calculadora.soma 1
Calculadora.soma 2
if Calculadora.total == 3
puts "teste passando"
else assert_equal 3, Calculadora.total
puts "teste falhou" end
end
end end
end
19. RSpec
it "should be equal 3 when add 1 and 2" do
class TestaCalculadora < Test::Unit::TestCase
def test_soma Calculadora.soma 1
Calculadora.soma 1 Calculadora.soma 2
Calculadora.soma 2
assert_equal 3, Calculadora.total Calculadora.total.should equal 3
end
end end
20. it "should be equal 3 when add 1 and 2" do Scenario: Summing 1 and 2
Calculadora.soma 1 Given a calculator
Calculadora.soma 2
When I add 1
Calculadora.total.should equal 3 And I add 2
end
Then the result should be 3
21. it "should be equal 3 when add 1 and 2" do Cenário: Somando 1 e 2
Calculadora.soma 1 Dado uma calculadora
Calculadora.soma 2
Quando eu somo 1
Calculadora.total.should equal 3 E eu somo 2
end
Então o resultado deve ser 3
38. Digitação não é o gargalo!
Quanto tempo gasta
consultando API?
Perguntando pra colegas
duvidas? etc
O que determina a
produtividade hoje,
é a qualidade de
ontem