I am new to use NUnit integration testing with Asp core 2.2, I have already core RESTful Api but have no idea how to configure NUnit to implement integration test. Usually I Implement it using Configuration file from Migration Folder as the following but no more exists in ASP Core 2.2 and I don't know what the new alternative.
var configuration = new Migrations.ApplicationDbContextModelSnapshot();
var migrator = new Migrator(configuration);
migrator.Update();
So please If you don't understand my question I just need an explicit link to use NUnit Integration Testing with.Net Core 2.2.
An integration test should not be connecting to a real database. Integration testing is about ensuring components function together correctly, not any concrete backend implementation. As such, you should be using the in-memory database provider for EF Core. This will automatically "migrate" (really it's just setting up a representation of what your database looks like in memory each time it's instantiated), so it's not necessary to take any further action. Just keep in mind that EF-in-memory database is also a non-relational database, so if you want to keep the relational integrity of your entities like the foreign keys, you should use SqlLite in-memory database. Below is an example:
var connection = new SqliteConnection("Data Source=:memory:");
services.AddDbContext<WebApi1DbContext>(options => options.UseSqlite(connection));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.