0

reading at fongo documentation i found that it supports the @Rule annotation to delete the contents of the DB before executing a test.

i want to achieve the same thing using TestNG but i can't find the correct way to do this, i tried calling fongo.dropDatabase(dbName) but it doesn't work as expected, if i call this method it seems that DB is droped but no new instance is created when inserting a new document.

also tried to delete and instance again fongo, but also no results. its the same i can create or update documents but if i try to fetch a document there will be no results.

to delete contents of fongo db i'm using @BeforeMethod annotation and there call to dropDatabase().

how should i delete db before every test?

lacripta
  • 112
  • 3
  • 15

1 Answers1

0

The easiest way is to call the JUnit rule by hand in @BeforeMethod and @AfterMethod: FongoRule#before() and FongoRule#after(). A better solution would use a TestNG listener.

But you should ask for a TestNG support in fongo: https://github.com/fakemongo/fongo/issues

juherr
  • 5,640
  • 1
  • 21
  • 63