I have three classes of tests, for two of them I need to disable the Spring Security context. The unit test are not performed using MockMvc so I cannot take advantage of @AutoConfigureMockMvc(addFilters = false)
. Is there a way to disable it in specific classes using annotations or do I need a profile and configure it to ignore the Spring Security context?
EDIT1: test code
@SpringBootTest
@Transactional
class VirtualMachineServiceUnitTests {
static List<Team> teams;
static List<VirtualMachine> virtualMachines;
static List<Configuration> configurations;
static List<VirtualMachineModel> models;
static List<Student> students;
static List<Course> courses;
@Autowired TeamRepository teamRepository;
@Autowired VirtualMachineRepository virtualMachineRepository;
@Autowired ConfigurationRepository configurationRepository;
@Autowired VirtualMachineModelRepository virtualMachineModelRepository;
@Autowired StudentRepository studentRepository;
@Autowired CourseRepository courseRepository;
@Autowired ModelMapper modelMapper;
@BeforeAll
static void beforeAll(@Autowired TeamRepository teamRepository,
@Autowired VirtualMachineRepository virtualMachineRepository,
@Autowired ConfigurationRepository configurationRepository,
@Autowired VirtualMachineModelRepository virtualMachineModelRepository,
@Autowired StudentRepository studentRepository,
@Autowired CourseRepository courseRepository) {
// ...
}
@Autowired
VirtualMachineService virtualMachineService;
@Test
void createVirtualMachine() {
// ...
}
Aucun commentaire:
Enregistrer un commentaire