GithubHelp home page GithubHelp logo

Comments (6)

almasaeed2010 avatar almasaeed2010 commented on August 28, 2024 2

Hi!

Here are a few things factories provide:

  • simple per table syntax
  • an easy way to generate multiple records by provide a second argument
  • however, they can’t be used to define complex operations such as using user_save() or entity_save()

Seeders:

  • usually used to run complex operations
  • can be run using the command line using “tripaltest db:seed”
  • the most important feature is that seeders can be used to populate the database with persistent data. So you’d run the seeder once to add the data and be able to use and test the GUI

BTW, both the seeder class and the tripal test case class provide a “$this->publish($chado_table_name, $record_id)” method to convert chado records into entities in case you wanted to run tests on entities

from tripaltestsuite.

almasaeed2010 avatar almasaeed2010 commented on August 28, 2024 1

Precisely!

from tripaltestsuite.

almasaeed2010 avatar almasaeed2010 commented on August 28, 2024 1

Seeders don't run automatically. You have to use MySeeder::seed() in the test method (which you can run within a transaction) or by running them through the command line which is not revertible.

from tripaltestsuite.

laceysanderson avatar laceysanderson commented on August 28, 2024

Oh, I think I see! :-) Thanks!

Just to check my understanding:

  • I would create a database seeder for creating fake "BlastDB" nodes used for testing the blast form or job since it should be done with node_save()?
  • I could use a factory for creating fake dbxrefs when testing "BlastDB" node CRUD and for use in the database seeder above?

from tripaltestsuite.

bradfordcondon avatar bradfordcondon commented on August 28, 2024

@almasaeed2010 do seeders do inserts only or updates? I'm thinking about seeders running multiple times and getting db errors because of it.

@laceysanderson i think if you are using seeders in the context of testing, then you'll want to a) run the seeders in the Travis container before running your tests and b) document that you need to run them for tests to pass for contributors. Factories on the other hand are meant to be lightweight, run once per test.

from tripaltestsuite.

bradfordcondon avatar bradfordcondon commented on August 28, 2024

oh thats neat, so running within test, with transactions, is do-able. So in that case its for "complex operations" as you say. Cool.

from tripaltestsuite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.