팩토리 걸은 테스트 용 모델 인스턴스를 쉽게 만들 수있는 편리한 프레임 워크입니다. Factory Girl home page에서Factory Girl과 같은 프레임 워크가 Java에 있습니까?
:
factory_girl가 신속하게 각 모델에 대한 프로토 타입을 정의하고 손에서 테스트의 중요한 속성 인스턴스를 요청 할 수 있습니다.
(홈 페이지도) 예 : 나는 사용자가 필요한 경우
Factory.sequence :email do |n|
"somebody#{n}@example.com"
end
# Let's define a factory for the User model. The class name is guessed from the
# factory name.
Factory.define :user do |f|
# These properties are set statically, and are evaluated when the factory is
# defined.
f.first_name 'John'
f.last_name 'Doe'
f.admin false
# This property is set "lazily." The block will be called whenever an
# instance is generated, and the return value of the block is used as the
# value for the attribute.
f.email { Factory.next(:email) }
end
A는 단지
test_user = Factory(:user, :admin => true)
를 호출 할 수 있습니다에 지정된 모든 속성을 가진 사용자를 얻을 것입니다 공장 프로토 타입 (명시 적으로 지정한 admin 속성의 경우 제외) 또한 전자 메일 팩터 리 메서드는 호출 될 때마다 다른 전자 메일을 생성합니다.
나는 Java와 비슷한 것을 구현하는 것이 꽤 쉬워야한다고 생각하지만 휠을 재발 명하고 싶지는 않습니다.
P.S : JMock과 EasyMoc에 대해 알고 있지만, 여기서 조롱하는 프레임 워크에 대해서는 언급하지 않았습니다.
FactoryGirl에 대한 예를 들려 주시겠습니까? 다른 곳으로 가서 읽지 않아도됩니까? – skaffman
그 frameworker의 권리 조합이 그 길에서 점점 더 시작될 때까지 파이썬에 대한 것이있었습니다! –
Beanmother https://github.com/keepcosmos/beanmother가 원하는 것입니다. –