'Automation Test executed by Runner works fine, but when execute this by command mvn, it gets error in test that already works fine
I am a QA and created a framework(JAVA) to execute my tests. Everything is going fine running the tests by Runners. All those tests works fine and got the PASSED status, but when i tried to execute mvn clean install, all the tests started to work and get PASSED until only one test get FAILED with the error:
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
at steps.StepDefinitions.sistema_retorna_erro_por_informao_invalida(StepDefinitions.java:132)
at ?.sistema retorna erro por informao
invalida(src/test/resources/features/fluxoaporteextra.feature:80)
To check this specific test, I isolated it using a @Tag in Features and running by Runner.java. Again the test was fine and got PASSED status.
So I isolated it the same way i did with this test to only it be tested by mvn clean install.
When i executed mvn clean install, only this test was executed and got again the same error above.
I don't know what is the difference between the ways of execute the test that occurs to take this error.
Did someone get the similar problem? Help!
Figured out this:
After check the responses and verification using sysout....i realized that the problem happens probably because the response brings a message and this message has accentuation on some letters. When i execute the tests by Runner.java, it works fine, but when it is by mvn command the letters with accentuation dont appear in message:
response by Runner.java:
{
"erro": [
{
"codigoErro": 44,
"nomeErro": "Não é possivel realizar distribuição do aporte extra para este valor ",
"descricaoErro": "Não é possivel realizar distribuição do aporte extra para este valor "
}
]
}
response by mvn:
{
"erro": [
{
"codigoErro": 44,
"nomeErro": "No possivel realizar distribuio do aporte extra para este valor ",
"descricaoErro": "No possivel realizar distribuio do aporte extra para este valor "
}
]
}
Now if someone has some idea what could solve this problem, please help me.
I created a method to solve this problem, probably there is a lib that does it too, but i coulnt find:
public static String trataAcentuacao(String valor) {
String[] nchar = { "ã", "õ", "á", "é", "í", "ó", "ú", "â", "ê", "î", "ô", "û", "ç", "à" };
String[] schar ={"ã","õ","á","é","Ã","ó","ú","â","ê","î","ô","û","ç","Ã"};
int i = 0;
while(i < schar.length){
if(valor.contains(schar[i])){
valor = valor.replace(schar[i], nchar[i]);
}
i++;
}
return valor;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|