Question: I'm testing using mockmvc. In Environment tab (Run -> Run Configurations ->tab Environment) I have username and password, and I'm using System.getenv in my controller

I'm testing using mockmvc. In Environment tab (Run -> Run Configurations ->tab Environment) I have username and password, and I'm using System.getenv in my controller class and get the username and password from the Environment tab. the problem is when I run mvn clean test from git bash I'm getting error for missing username and password. I want to keep the username and password in Environment tab so all my controllers classes will get the username and password from the Environment tab. how I can solve that:

testing class

@RunWith(SpringRunner.class)

@webMvcTest(conteollers=intra.class)

public class Testintra {

@Autowird

MockMvc mockMvc;

@Test

public void getread() throws Exception{

MvcResult result=mockMvc.perform(post("/rep/name").param("Group","req")).andExpect(Status().isOk)

.andReturn();

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!