Too many SOQL queries: 101 issue with Unit Test Methods

By using the Test.startTest() & Test.stopTest() you get 2X governer limits.

In nutshell you have 2 context.

  1. out side of Test.startTest() & Test.stopTest() and
  2. inside of Test.startTest() & Test.stopTest().

In both context you get separate limits.

To fix this issue what you will have to do is:

  1. Optimize and see if you can reduce the queries in trigger
  2. Reduce the number of objects you are inserting
  3. You can skip unnecessary trigger execution by checking if trigger being called by Test method if(Test.isRunningTest())
  4. in worst case you can use SeeAllData = ture