0

conider class abc here condition we already write test case for Some_Another_Method() and than we need to write unit test case for some_method(); how to write xunit test case for nested methods ?

class abc 
{
    public void some_method()
    {
        //doing something which also need unit test 
        //some database calls       
        Some_Another_Method();
        
        ///doing something which also need unit test 
        //some database calls 
        
    }
    public void Some_Another_Method()
    {
             //doing something which also need unit test 
        //some database calls
        
    }   
}

Try to write xunit test case for nested methods

  • 1
    there's no nested method here, but just a call to another public method. Seems like `some_method` is in fact some integrational method, thus you should write an integration-test. There's no general rule how to test that method, I'd argue to write a single test calling it regardless on how `some_Another_method` behaves. – MakePeaceGreatAgain Apr 12 '23 at 10:27

0 Answers0