Published
Jul 7, 2026
3mo ago
Total Downloads
2.4M
2,352,137
Install
dotnet add package RavenDB.TestDriver --version 7.2.5-rc-72023
| Product | Versions |
|---|---|
| .NET Standard | |
| Other |
README
RavenDB .NET Test Driver
You're looking at RavenDB Test Driver Client (SDK) NuGet release.
It makes it easy to write tests that require RavenDB instance, leveraging embedded server and providing you friendly API.
RavenDB is a NoSQL database that fuses extreme performance with ease-of-use, offering above the roof developer experience.
Learn more at https://ravendb.net or visit our GitHub repository.
Installation
Get the latest stable version from NuGet.
Learning resources
- Test Driver Guide - https://ravendb.net/articles/writing-unit-tests-with-ravendb-net-test-driver π£οΈ
- Documentation - https://ravendb.net/docs/article-page/start/test-driver π
- Code Samples - https://demo.ravendb.net/ π§βπ»
Community
- RavenDB's Discord - https://discord.gg/ravendb π»
- Articles & guides - https://ravendb.net/articles π°
- YouTube - https://www.youtube.com/@ravendb_net πΏ
- Blog - https://ayende.com/blog/ π§βπ»
Getting started
Configure
var testServerOptions = new TestServerOptions
{
// Looks for the newest version on your machine including 3.1.15 and any newer patches
// but not major new releases (default is .NET version at time of server release).
FrameworkVersion = "3.1.15+",
// Specifies where ravendb server binaries are located (Optional)
ServerDirectory = "PATH_TO_RAVENDB_SERVER",
// Specifies where ravendb data will be placed/located (Optional)
DataDirectory = "PATH_TO_RAVENDB_DATADIR",
};
ConfigureServer(testServerOptions);
Write a test
using Raven.Client.Documents;
using Raven.TestDriver;
using Xunit;
using System.Linq;
using Raven.Client.Documents.Indexes;
namespace RavenDBTestDriverFullExample
{
public class RavenDBTestDriver : RavenTestDriver
{
static RavenDBTestDriver()
{
// ConfigureServer() must be set before calling GetDocumentStore()
// and can only be set once per test run.
ConfigureServer(new TestServerOptions
{
DataDirectory = "C:\\RavenDBTestDir"
});
}
// This allows us to modify the conventions of the store we get from 'GetDocumentStore'
protected override void PreInitialize(IDocumentStore documentStore)
{
documentStore.Conventions.MaxNumberOfRequestsPerSession = 50;
}
[Fact]
public void MyFirstTest()
{
// GetDocumentStore() evokes the Document Store, which establishes and manages communication
// between your client application and a RavenDB cluster via HTTP requests.
using (var store = GetDocumentStore())
{
store.ExecuteIndex(new TestDocumentByName());
using (var session = store.OpenSession())
{
session.Store(new TestDocument { Name = "Hello world!" });
session.Store(new TestDocument { Name = "Goodbye..." });
session.SaveChanges();
}
// If we want to query documents, sometimes we need to wait for the indexes to catch up
// to prevent using stale indexes.
WaitForIndexing(store);
// Sometimes we want to debug the test itself. This method redirects us to the studio
// so that we can see if the code worked as expected (in this case, created two documents).
WaitForUserToContinueTheTest(store);
// Queries are defined in the session scope.
// If there is no relevant index to quickly answer the query, RavenDB creates an auto-index
// based on the query parameters.
// This query will use the static index defined in lines 63-70 and filter the results by name.
using (var session = store.OpenSession())
{
var query = session.Query<TestDocument, TestDocumentByName>()
.Where(x => x.Name == "hello").ToList();
Assert.Single(query);
}
}
}
}
// AbstractIndexCreationTask allows you to create and manually define a static index.
public class TestDocumentByName : AbstractIndexCreationTask<TestDocument>
{
public TestDocumentByName()
{
Map = docs => from doc in docs select new { doc.Name };
Indexes.Add(x => x.Name, FieldIndexing.Search);
}
}
public class TestDocument
{
public string Name { get; set; }
}
}
Contributing
- Submit an issue - https://github.com/ravendb/ravendb/issues
- GitHub Discussions - https://github.com/ravendb/ravendb/discussions
- Contributing rules - https://github.com/ravendb/ravendb/blob/v7.2/CONTRIBUTING.md
Changes from Previous Version
No structural changes between v7.2.4 and v7.2.5-rc-72023.
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
This version is marked prerelease. Validate its API and upgrade path before production use.No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.The published metadata declares 29 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.