Skip to content

Add support for defining explicit dependencies to QA factories

What does this MR do?

This MR adds support for specifying explicit dependencies in QA factories.

##
# It is possible to define an explicit dependency when
# building a factory object.
#
# Factories also return value objects and you can access these
# objects by a factory name, like `group` below.
#

module QA::Factory
  module Resource::Something < Factory::Base
    dependency Factory::Resource::Group do |group|
      group.name = 'my-group'
    end

    def fabricate!
      group.visit!

      # create a resource
    end
  end
end

##
# This can be also done explicitly.
#

module QA
  describe 'something' do
    it 'creates needed resources' do
      project = Factory::Resource::Project.fabricate! do |project|
        project.name = 'my-awesome-project'
      end

      branch = Factory::Resource::Branch.fabricate! do |branch|
        branch.project = project
        branch.name = 'qa/gb/add-explicit-dependencies'
      end

      branch.visit!
      # or 
      Factory::Repository::Push # ... use branch or something else
    end
  end
end

Does this MR meet the acceptance criteria?

  • Has been reviewed by Backend

What are the relevant issue numbers?

Closes gitlab-qa#122 (closed)

Edited by Grzegorz Bizon

Merge request reports