If I activate a Profile in Tests with @ActiveProfiles, say @ActiveProfiles("test"), and declare @Mock private ConfigurableEnvironment environment in test, will I be able to retrieve environment.getProperty("spring.profiles.active"). I am getting the value as null.
Example test is as follows
@RunWith(SpringJUnit4ClassRunner.class)
@WebMvcTest(value = ProductController.class)
@ActiveProfiles("test)
class ProductControllerTest{
@Autowired
private MockMvc mockMvc;
@MockBean
private ProductServiceImpl productServiceImpl;
@Mock
private ConfigurableEnvironment enviroment;
@Before
public void setup(){
MockitoAnnotations.initMocks(this);
}
@Test
public void test() throws Exception{
String profile = environment.getProperty("spring.profiles.active"); // -> This returns null ...why ? If i am setting ActiveProfile as test ..why does above return null?
}
}