RedJocker / BlackboardTestCreation

0 stars 1 forks source link

stage2 test12 - error message #10

Closed RedJocker closed 9 months ago

RedJocker commented 9 months ago

@OrifjonOlimjonov on your last pull request there was a commit saying

test12 has been fixed

in which you added this code

https://github.com/RedJocker/BlackboardTestCreation/blob/4a5b0c68f372724c29a167709d8619244a08d798/Blackboard/stage2/src/main/java/org/hyperskill/blackboard/ui/login/LoginFragment.kt#L58-L59

Can you elaborate on why of that change? On machines I tested that message was the one that was given by the exception that was thrown and the message was being set by these code

https://github.com/RedJocker/BlackboardTestCreation/blob/4a5b0c68f372724c29a167709d8619244a08d798/Blackboard/stage2/src/main/java/org/hyperskill/blackboard/ui/login/LoginViewModel.kt#L87-L97

https://github.com/RedJocker/BlackboardTestCreation/blob/4a5b0c68f372724c29a167709d8619244a08d798/Blackboard/stage2/src/main/java/org/hyperskill/blackboard/ui/login/LoginFragment.kt#L80-L87

https://github.com/RedJocker/BlackboardTestCreation/blob/4a5b0c68f372724c29a167709d8619244a08d798/Blackboard/stage2/src/main/java/org/hyperskill/blackboard/ui/login/LoginFragment.kt#L94-L98

Were you having issues without adding that line of code?

OrifjonOlimjonov commented 9 months ago

when I run the test , I get following error.

изображение

I saw these codes but couldn't figure out why it didn't work.

OrifjonOlimjonov commented 9 months ago

Then, I thought here it is only checked that it is not null. And there is no address validation in the solution.

изображение

OrifjonOlimjonov commented 9 months ago

https://github.com/RedJocker/BlackboardTestCreation/blob/4a5b0c68f372724c29a167709d8619244a08d798/Blackboard/stage2/src/main/java/org/hyperskill/blackboard/ui/login/LoginViewModel.kt#L87-L97

https://github.com/RedJocker/BlackboardTestCreation/blob/4a5b0c68f372724c29a167709d8619244a08d798/Blackboard/stage2/src/main/java/org/hyperskill/blackboard/ui/login/LoginFragment.kt#L80-L87

https://github.com/RedJocker/BlackboardTestCreation/blob/4a5b0c68f372724c29a167709d8619244a08d798/Blackboard/stage2/src/main/java/org/hyperskill/blackboard/ui/login/LoginFragment.kt#L94-L98

After the test didn't work, I thought that the only errors that could occur in these codes were that the localhost check was missing or not relevant to the case in the test.

RedJocker commented 9 months ago

when I run the test , I get following error.

изображение

I saw these codes but couldn't figure out why it didn't work.

hmmmm....

this is what the log should look like

baseUrlMockWebServer http://localhost:62221/
baseUrl : http://invalid/url/
LoginFragment.onCreateView
LoginFragment.onViewCreated
credential.observe: null
messageLoginError.observe: null
messageNetworkError.observe: null
clearEtError
clearEtError
click loginSubmitBtn
http://invalid/url/login
onFailure
java.net.UnknownHostException: invalid: nodename nor servname provided, or not known
    at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(Unknown Source)
    at java.base/java.net.InetAddress.getAddressesFromNameService(Unknown Source)
    at java.base/java.net.InetAddress$NameServiceAddresses.get(Unknown Source)
    at java.base/java.net.InetAddress.getAllByName0(Unknown Source)
    at java.base/java.net.InetAddress.getAllByName(Unknown Source)
    at java.base/java.net.InetAddress.getAllByName(Unknown Source)
    at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
    at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
    at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
    at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
    at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
    at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
    at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
    at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
    at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

messageNetworkError.observe: invalid: nodename nor servname provided, or not known
LoginFragment.onNetworkError invalid: nodename nor servname provided, or not known
messageLoginError.observe: null
RedJocker commented 9 months ago

for some reason it looks like the exception is not being thrown and onFailure is not being called

RedJocker commented 9 months ago

@OrifjonOlimjonov try removing that code from implementation and changing to this on LoginScreen

fun assertLoginNetworkError(caseDescription: String, expectedError: String) = with(test) {
        shadowLooper.runToEndOfTasks()
        Thread.sleep(300)           // Callback.onResponse is async
        shadowLooper.runToEndOfTasks()  // runOnUiThread goes to Handler queue

        blackboardTitle.assertError(expectedError, BLACKBOARD_TITLE_ID, caseDescription)
        loginUsernameEt.assertError(null, LOGIN_USERNAME_ET_ID, caseDescription)
        loginPassEt.assertError(null, LOGIN_PASS_ET_ID, caseDescription)
    }
RedJocker commented 9 months ago

if it still does not work try exaggerating on Thread.sleep just to see if there is some kind of timeout limit that is different in your system

OrifjonOlimjonov commented 9 months ago

When threed.sleep(5000) it threw the following error.


baseUrl : http://invalid/url/
LoginFragment.onCreateView
LoginFragment.onViewCreated
credential.observe: null
messageLoginError.observe: null
messageNetworkError.observe: null
clearEtError
clearEtError
click loginSubmitBtn
http://invalid/url/login
onFailure
java.net.UnknownHostException: No such host is known (invalid)
    at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:933)
    at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1534)
    at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:852)
    at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1524)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1381)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1305)
    at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
    at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
    at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
    at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
    at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
    at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
    at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
    at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
    at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

messageNetworkError.observe: No such host is known (invalid)
LoginFragment.onNetworkError No such host is known (invalid)
messageLoginError.observe: null

With invalid baseUrl leading to network error, on property error of TextView with id blackboard_title expected:<[invalid: nodename nor servname provided, or not known]> but was:<[No such host is known (invalid)]>
Expected :invalid: nodename nor servname provided, or not known
Actual   :No such host is known (invalid)
OrifjonOlimjonov commented 9 months ago

hmmmm....

this is what the log should look like

baseUrlMockWebServer http://localhost:62221/
baseUrl : http://invalid/url/
LoginFragment.onCreateView
LoginFragment.onViewCreated
credential.observe: null
messageLoginError.observe: null
messageNetworkError.observe: null
clearEtError
clearEtError
click loginSubmitBtn
http://invalid/url/login
onFailure
java.net.UnknownHostException: invalid: nodename nor servname provided, or not known
  at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
  at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(Unknown Source)
  at java.base/java.net.InetAddress.getAddressesFromNameService(Unknown Source)
  at java.base/java.net.InetAddress$NameServiceAddresses.get(Unknown Source)
  at java.base/java.net.InetAddress.getAllByName0(Unknown Source)
  at java.base/java.net.InetAddress.getAllByName(Unknown Source)
  at java.base/java.net.InetAddress.getAllByName(Unknown Source)
  at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
  at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
  at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
  at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
  at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
  at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
  at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
  at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
  at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
  at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
  at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
  at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
  at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at java.base/java.lang.Thread.run(Unknown Source)

messageNetworkError.observe: invalid: nodename nor servname provided, or not known
LoginFragment.onNetworkError invalid: nodename nor servname provided, or not known
messageLoginError.observe: null

How does this error occur? it's not happening to me.

RedJocker commented 9 months ago

That is the error we were looking for, your system is just giving a different message. The real problem is having to wait 5s to have that message. For the different message we could change to something simpler like checking the message is not null, but we should not have a test that take take long to run. Can that same error be observed with less than 1s?

RedJocker commented 9 months ago

ok nevermind, I wrote a different test to check network error message that does not depend on throwing error.

I sent it on referenceSolution branch, please check that if it is ok in your system too.

I was already preparing main branch to publish.

OrifjonOlimjonov commented 9 months ago

Can that same error be observed with less than 1s?

No

OrifjonOlimjonov commented 9 months ago

ok nevermind, I wrote a different test to check network error message that does not depend on throwing error.

I sent it on referenceSolution branch, please check that if it is ok in your system too.

I was already preparing main branch to publish.

everything is working fine.

RedJocker commented 9 months ago

everything is working fine.

great