This test wrong at many points: - test returns before calling ParentServlet, which is responsible for ChildServlet registration; - webclient calls wrong URLs (/ is redundant and don't match with mappings); - mapping for ChildServlet isn't set (dynamically) - fail(..) statement prevents execution of meaningful part of the test; - and finally it wouldn't work because programmatic registration is impossible after ServletContext initialization is finished.