Trace: » importantconcepts » flowmode » targetobject » writingtestsinexcel » databaseunittests » tablefixture » variaveisdemarcacao » argumentosparafixtures » webtest » actionfixture
ActionFixture
ActionFixture foi originalmente pensada para testes de workflow que não são repetitivos. Ela usa interface com o usuário como uma métafora para automatizar outras fixtures.
Formato da tabela
A primeira linha de uma tabela que use ActionFixture sempre inicia a classe da fixture, neste caso a própria ActionFixture e não uma subclasse. Todas as linhas depois da primeira começam com uma célula de comando, seguida de argumentos nas próximas células. Algumas linhas terão duas células e outras terão três. A segunda linha é tipicamente usada para o comando start que espera um argumento -- o nome da classe da fixture a ser automatizada. Depois disso, você pode usar os seguintes comandos para automatizar seu teste:
check-- executa um método e verifica seu valor.press-- executa um métodovoidsem testar nada.enter-- executa um método e passa um argumento para ele.
ActionFixture como uma ferramenta automatizada para popular formulários e clicar em botões que estão conectados com os métodos.
!|ActionFixture| |start|ActionFixtureTest| |enter|firstPart|Hello| |enter|secondPart|World| |press|join| |check|together|Hello, World|
Classe de suporte (fixture)
Uma diferença importante entre ActionFixture e todas outras fixtures é que você não deve estender a classe ActionFixture para usá-la. Ao invés disso, você deve estender fit.Fixture diretamente na sua fixture e passá-la para a ActionFixture usando o comando start .
Código-fonte em Java
package info.fitnesse.fixturegallery;
public class ActionFixtureTest extends fit.Fixture{
private String first, second, both;
public void firstPart(String s){
first=s;
}
public void secondPart(String s){
second=s;
}
public void join(){
both=first+ ", "+second;
}
public String together(){
return both;
}
}
Código-fonte em .Net
using System;
namespace info.fitnesse.fixturegallery
{
public class ActionFixtureTest: fit.Fixture
{
public String firstPart, secondPart, together;
public void join()
{
together=firstPart+ ", "+secondPart;
}
}
}
Código-fonte em Python
from fit.Fixture import Fixture
class ActionFixtureTest(Fixture):
_typeDict = {}
def __init__(self):
Fixture.__init__(self)
self.__first = "" #< Private attributes (Python convention).
self.__second = ""
self.__both = ""
# JAVA: void firstPart(String s)
_typeDict["firstPart"] = "String"
def firstPart(self, s):
self.__first = s
# JAVA: void secondPart(String s)
_typeDict["secondPart"] = "String"
def secondPart(self, s):
self.__second = s
# JAVA: void join()
_typeDict["join"] = "Default" #< AUTO-DETECT: None = void
def join(self):
self.__both = "%s, %s" % (self.__first, self.__second)
# JAVA: String together()
_typeDict["together"] = "String"
def together(self):
return self.__both
Código-fonte em Smalltalk
'From VisualWorks®, 7.6 of March 3, 2008 on June 27, 2008 at 3:36:11 pm'!
Info.Fitnesse.Fixturegallery defineClass: #ActionFixtureTest
superclass: #{Fit.Fixture}
indexedType: #none
private: false
instanceVariableNames: 'first second both '
classInstanceVariableNames: ''
imports: ''
category: ''!
!Info.Fitnesse.Fixturegallery.ActionFixtureTest methodsFor: 'accessing'!
firstPart: aString
first := aString!
secondPart: aString
second := aString!
together
^both! !
!Info.Fitnesse.Fixturegallery.ActionFixtureTest methodsFor: 'actions'!
join
both := first , ', ' , second! !
!Info.Fitnesse.Fixturegallery.ActionFixtureTest methodsFor: 'type access'!
signatureFor: aSymbol
aSymbol == #together ifTrue: [^String].
^MethodSignature with: String! !
Observações
Na versão Java, ActionFixture funciona apena com métodos. Na versão .Net, enter e check podem tanto setar quanto verificar atributos.
Utilização
Você pode usar a ActionFixture para descrever verificações no estilo interface com o usuário.
Em geral, ActionFixture foi substituída pela DoFixture (veja DoFixture ) e existem poucas razões para você querer utilizar uma ActionFixture hoje em dia. DoFixture permite escrever testes para workflow muito mais facilmente, com menos código tanto na fixture quanto na tabela em FitNesse. Ela também permite encapsular diretamente objetos de domínio.
Página anterior: ColumnFixture Próxima página: RowFixture Página acima: Fixtures básicas de FIT
