Open Closed

IDataSeedContributor exectuion order in UnitTests #571


User avatar
0
ab created
  • ABP Framework version: v3.3.0

Hello,

within my tests I have several DataSeedContributor implementation that inherit from IDataSeedContributor However, some test data seeds needs to be executed before another seed to make valid test data possible (e.g. I like to execute the OrderDataSeedContributor before the OrderItemsDataSeedContributor before since OrderItems are related to Orders).

Now I like to control the exectuion order of the DataSeedContributor. I found that the DataSeeds are executed here

    await scope.ServiceProvider
                        .GetRequiredService<IDataSeeder>()
                        .SeedAsync();

How can I control the execution order?

Thanks!

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Unfortunately the order cannot be determined, You can add dependency injection completely manually, but it is hard work. You'd better initialize the seed data in the same contributor

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ab created

    Thank you for your reply! What do you mean with "You'd better initialize the seed data in the same contributor"?

    Do you mean that I should combine all seed data in the same class/ method?

    Thank you

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    (e.g. I like to execute the OrderDataSeedContributor before the OrderItemsDataSeedContributor before since OrderItems are related to Orders).

    You can initialize orders and order items in OrderDataSeedContributor

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.