In other news: Environmental stories from around the web, January 11, 2019

first_imgArticle published by John Cannon Popular in the CommunitySponsoredSponsoredOrangutan found tortured and decapitated prompts Indonesia probeEMGIES17 Jan, 2018We will never know the full extent of what this poor Orangutan went through before he died, the same must be done to this evil perpetrator(s) they don’t deserve the air that they breathe this has truly upset me and I wonder for the future for these wonderful creatures. So called ‘Mankind’ has a lot to answer for we are the only ones ruining this world I prefer animals to humans any day of the week.What makes community ecotourism succeed? In Madagascar, location, location, locationScissors1dOther countries should also learn and try to incorporateWhy you should care about the current wave of mass extinctions (commentary)Processor1 DecAfter all, there is no infinite anything in the whole galaxy!Infinite stupidity, right here on earth.The wildlife trade threatens people and animals alike (commentary)Anchor3dUnfortunately I feel The Chinese have no compassion for any living animal. They are a cruel country that as we knowneatbeverything that moves and do not humanily kill these poor animals and insects. They have no health and safety on their markets and they then contract these diseases. Maybe its karma maybe they should look at the way they live and stop using animals for all there so called remedies. DisgustingConservationists welcome China’s wildlife trade banThobolo27 JanChina has consistently been the worlds worst, “ Face of Evil “ in regards our planets flora and fauna survival. In some ways, this is nature trying to fight back. This ban is great, but the rest of the world just cannot allow it to be temporary, because history has demonstrated that once this coronavirus passes, they will in all likelihood, simply revert to been the planets worst Ecco Terrorists. Let’s simply not allow this to happen! How and why they have been able to degrade this planets iconic species, rape the planets rivers, oceans and forests, with apparent impunity, is just mind boggling! Please no more.Probing rural poachers in Africa: Why do they poach?Carrot3dOne day I feel like animals will be more scarce, and I agree with one of my friends, they said that poaching will take over the world, but I also hope notUpset about Amazon fires last year? Focus on deforestation this year (commentary)Bullhorn4dLies and more leisSponsoredSponsoredCoke is again the biggest culprit behind plastic waste in the PhilippinesGrapes7 NovOnce again the article blames companies for the actions of individuals. It is individuals that buy these products, it is individuals that dispose of them improperly. If we want to change it, we have to change, not just create bad guys to blame.Brazilian response to Bolsonaro policies and Amazon fires growsCar4 SepThank you for this excellent report. I feel overwhelmed by the ecocidal intent of the Bolsonaro government in the name of ‘developing’ their ‘God-given’ resources.U.S. allocates first of $30M in grants for forest conservation in SumatraPlanet4dcarrot hella thick ;)Melting Arctic sea ice may be altering winds, weather at equator: studyleftylarry30 JanThe Arctic sea ice seems to be recovering this winter as per the last 10-12 years, good news.Malaysia has the world’s highest deforestation rate, reveals Google forest mapBone27 Sep, 2018Who you’re trying to fool with selective data revelation?You can’t hide the truth if you show historical deforestation for all countries, especially in Europe from 1800s to this day. WorldBank has a good wholesome data on this.Mass tree planting along India’s Cauvery River has scientists worriedSurendra Nekkanti23 JanHi Mongabay. Good effort trying to be objective in this article. I would like to give a constructive feedback which could help in clearing things up.1. It is mentioned that planting trees in village common lands will have negative affects socially and ecologically. There is no need to even have to agree or disagree with it, because, you also mentioned the fact that Cauvery Calling aims to plant trees only in the private lands of the farmers. So, plantation in the common lands doesn’t come into the picture.2.I don’t see that the ecologists are totally against this project, but just they they have some concerns, mainly in terms of what species of trees will be planted. And because there was no direct communication between the ecologists and Isha Foundation, it was not possible for them to address the concerns. As you seem to have spoken with an Isha spokesperson, if you could connect the concerned parties, it would be great, because I see that the ecologists are genuinely interested in making sure things are done the right way.May we all come together and make things happen.Rare Amazon bush dogs caught on camera in BoliviaCarrot1 Feba very good iniciative to be fallowed by the ranchers all overSponsored There are many important conservation and environmental stories Mongabay isn’t able to cover.Here’s a digest of some of the significant developments from the week.If you think we’ve missed something, feel free to add it in the comments.Mongabay does not vet the news sources below, nor does the inclusion of a story on this list imply an endorsement of its content. Tropical forestsScientists set up a mirror for wildlife in the rainforest, with comical results (Sputnik News).Researchers in Ecuador discover a new species of frog with a thumb-claw (Newsweek).In late 2018, an eastern bongo, a critically endangered antelope from East Africa, was born at a Florida zoo (First Coast News, News 4 Jacksonville).Researchers argue that dams built in lowland rainforests are too costly to biodiversity to be justified (Phys.Org/University of Stirling).As Colombia’s forests fall, organized crime profits rise (Insight Crime).California’s plan for carbon trading could infringe upon communities’ rights, leaders say (Devdiscourse).Forest clearing for oil palm plantations in Borneo is affecting the group size of proboscis monkeys (Phys.Org/Cardiff University).Tanzania began a six-month push to root out illegal logging in the country (Khmer Times, Xinhua).Haiti could lose half of its species to deforestation-related habitat loss by 2035 (WHYY Philadelphia).Tree plantations in Southeast Asia are becoming a popular investment in China (South China Morning Post).Illegal logging led to landslides in Indonesia (The Jakarta Post).A female bongo died after complications from a cesarean section birth in Virginia (WAVY).Other newsRanchers across the western United States struggle to cope with increasing numbers of wolves (Pacific Standard).Warmer water is causing problems for Guadalupe fur seals (Hakai Magazine).Climate change is throwing off Australia’s “thermostat,” the Great Barrier Reef (Hakai Magazine).Proponents of a dam project in Tanzania’s Selous Game Reserve say its construction is necessary for the country’s economic development (IPP Media).The U.S. government shutdown is hampering wildlife conservation work (WBUR Boston).Wild animals are beginning to use a highway overpass in the state of Washington (Smithsonian Magazine).A bustling economy kept U.S. carbon emissions high in 2018, despite the closure of coal-fired power plants (The New York Times, The Washington Post).Banner image of an eastern bongo in Kenya by Chuckupd via Wikimedia Commons (Public domain).FEEDBACK: Use this form to send a message to the author of this post. If you want to post a public comment, you can do that at the bottom of the page.center_img Conservation, Environment, Weekly environmental news update last_img read more

Preview: 2010 World Cup Group G

first_imgEnd of 2009 Fifa ranking: 86Appearances: 1Best result: quarterfinals 1966Players to watch: midfielder Mun In-Guk and forwards Hong Yong-Jo and Jong Tae-Se During 2009, the Ivorians were unbeaten, winning five games and drawing four. They didn’t lose a single match in qualifying. Would you like to use this article in your publication or on your website? See: Using SAinfo material There were a couple of head-scratching defeats mixed in among what was generally a good run of results: a 1-0 loss to Lebanon at home and a 4-1 defeat in Zambia topped the list. Overall, in 2009, North Korea won six matches, drew four, and lost three. End of 2009 Fifa ranking: 5Appearances: 4Best result: third 1966Players to watch: defenders Ricardo Carvalho and Pepe, midfielder Deco, forwards Simao Sabrosa and Cristiano Ronaldo End of 2009 Fifa ranking: 2Appearances: 18Best result: champions 1958, 1962, 1970, 1994, 2002Players to watch: goalkeeper Julio Cesar, defender Lucio, midfielder Kaka, and forwards Adriano, Luis Fabiano, and Robinho North Korea In addition, their poor results didn’t come in 2009. In fact, they were unbeaten during the year, playing 12 matches, winning eight of them and drawing the other four. Considering their excellent form during 2009, as well as a fourth-place finish in Germany in 2006, Portugal will be aiming to win it all in South Africa. Their clash with Brazil will be one of the most eagerly-awaited contests of the group stages. Portugal weren’t seeded after finishing second in their qualifying group behind Denmark. That resulted in the Portuguese playing off against Bosnia and Herzegovina for a place in South Africa 2010. However, they are a team loaded with quality and a world ranking of fifth speaks volumes about their ability. While Group G is headlined by Brazil, it is known as the Group of Death because of the presence of Portugal and also because of the Ivory Coast, a team ranked 16th in the world that features some top class talent, including one of the world’s best strikers. Portugal is coached by Carlos Queiroz, formerly coach of Bafana Bafana, which makes him familiar with South African conditions. While 2008 Fifa World Player of the Year Cristiano Ronaldo is undoubtedly the star attraction, fellow forward Simao is a handful for opposition defences with his dribbling ability and set piece skills. The undoubted star of their team is striker Didier Drogba, who has proven himself with Chelsea on the biggest stages in Europe to be one of the world’s leading strikers and certainly one of the most difficult to contain. His Chelsea team-mate Salomon Kalou provides excellent wide support up front. Most importantly, Portugal has an excellent defence, which features a good mix of experience and youth. During 2009, they conceded only two goals in their 12 matches! That kind of defensive record is a fine foundation from which to win matches. The good performances by North Korean women’s teams at international age group World Cups – winners at under-17 level and runners-up at under-20 – is indicative of the fact that the country has football talent and good coaching. However, some of their results in 2009 were not as encouraging. Ivory Coast center_img Only one result is good enough for the Seleçao and their supporters and that is victory. Under coach Dunga, a defensive midfielder in his day, Brazil came around slowly, but he now has them playing with confidence in his way. They will be tough to beat in South Africa and their Confederations Cup success will surely prove to be invaluable in the World Cup. The Ivorians, with the quality of their squad and their experience of African conditions, are certainly a dark horse team to beware of, even though their group includes two of the world’s top five nations. For Brazil, 2009 was a very busy, but successful year. They lifted the Fifa Confederations Cup in South Africa, winning every single match on their way to the title. They also won 14 of the 17 matches they played, lost only one and drew two others. They scored 38 goals and conceded only 12 and along the way defeated, among others, Italy (twice), England, Argentina, and Chile. North Korea has qualified for the World Cup once previously, in 1966, and they acquitted themselves very well on that occasion. They shocked Italy 1-0 to win through to the quarterfinals. There, they took a 3-0 lead over a very strong Portuguese team, before exiting 5-3. In fact, with many of their players plying their trade in Europe with top clubs, the Elephants have a battle-hardened squad of players that is used to the pressure of having to perform against top class opposition on big stages. That makes them very dangerous. End of 2009 Fifa ranking: 16Appearances: 1Best result: first round 2006Players to watch: defenders Kolo Toure and Emmanuel Eboue, midfielders Didier Zokora and Yaya Toure, forwards Salomon Kalou and Didier Drogba Brazil-Portugal will be one of the most eagerly awaited of all group matches: it features the only group clash of teams ranked among the top five in the world and, while Brazil traditionally boasts flair, Portugal has at least one player with the ability to trump any Brazilian. Brazil In 2010, thanks to the secretive nature of the communist country, their abilities are somewhat unknown, although they did enjoy a good World Cup qualifying campaign. They finished second in their group behind their neighbours, South Korea, and ahead of Saudi Arabia on goal difference. Their reward was hardly a friendly welcome back to the World Cup, with Brazil, Portugal, and the Ivory Coast all teams of the highest quality. Portugal The Brazilians have one of the world’s leading playmakers in midfielder Kaka, while strikers Luis Fabiano and Adriano are proven finishers at international level. Goalkeeper Julio Cesar anchors a stingy defence, with experienced defender Lucio patrolling the ground in front of him. While the current team might not play the free-flowing football for which Brazil is traditionally renowned, they have the individual quality and the team ethic under coach Dunga – himself a former World Cup winning captain in 1994 – to make them a tough opponent for any team they face. The Koreans’ greatest strength is the lack of knowledge about them but, faced with the quality teams in their group, they will have an almost impossible task to reach the round of 16. With their superb record of being the only country to contest every Fifa World Cup™, being five-time winners, twice runners-up, and beaten in the semi-finals three times, Brazil will rightly be regarded as one of the favourites to lift the World Cup trophy in South Africa.last_img read more

Amazon Black Friday Deals Can’t Keep Up With Demand

first_imgWhy Tech Companies Need Simpler Terms of Servic… Related Posts mike melanson 8 Best WordPress Hosting Solutions on the Market Tags:#Amazon#news#web center_img Let the madness begin. This Friday, also known as “Black Friday”, is the busiest shopping day of the season in the U.S.. For Amazon users, however, the day known for profit-busting deals has been extended into a weeklong affair known as Amazon’s Black Friday Deals Week.The online event kicked off this morning and already there is a flood of complaints that you can’t click fast enough to get in on the savings.Amazon describes the events as running from Monday to Friday and “offering hundreds of deals on thousands of products, at must-have prices.” Those “must-have prices”, though, don’t seem to last very long.According to CNet U.K., “the mood has turned sour for many in Amazon’s own forums, with threads entitled Amazon deals only last a second, and Damage to reputation, business and customer trust, and Absolutely load of tosh! Amazon deals available for all of 2 seconds!! Boycot them!!.”Another blog describes the situation, saying that “A lot of people who were patiently waiting for the Amazon Black Friday deals were disappointed, as frenzy erupted as soon as the site opened its doors. […] Users excitedly logged in to the site only to be disappointed that almost all of the great deals were taken.”Looking at the Black Friday Deals page, however, shows plenty of “Lightning Deals” that seem to be lasting well long enough to get in on the discounts.To get a jump on the competition, CNet suggests following Amazon’s Facebook page. The company has also created a Twitter account to announce this weeks deals. Maybe, just maybe, if you’re quick on the digital draw, you too can get a copy of Susan Boyle’s latest and greatest hits. Rejoice in one thing, at least, if you don’t – you weren’t caught up in a discount induced stampede if you miss out.Also, keep an eye out here this week, as we’ll be looking for more hot iPhone apps and online sources for Black Friday deals. Top Reasons to Go With Managed WordPress Hosting A Web Developer’s New Best Friend is the AI Wai…last_img read more

How To Improve Test Coverage For Your Android App Using Mockito And Espresso

first_img Large previewUpon a click of the play button, the test version of the app will be installed on the emulator or device, and the test will run automatically on it. @Component.Builder interface Builder { fun appModule(appModule: AppModule): Builder fun build(): AppComponent } override fun onCreate(arguments: Bundle) { StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().permitAll().build()) super.onCreate(arguments) } Large previewWriting Local Unit TestsUnit tests can be run locally on your development machine without a device or an emulator. This testing approach is efficient because it avoids the overhead of having to load the target app and unit test code onto a physical device or emulator every time your test is run. In addition to Mockito, you will also need to configure the testing dependencies for your project to use the standard APIs provided by the JUnit 4 framework.Setting Up The Development EnvironmentStart by adding a dependency on JUnit4 in your project. The dependency is of the type testImplementation, which means that the dependencies are only required to compile the test source of the project.testImplementation ‘junit:junit:4.12’We will also need the Mockito library to make interaction with Android dependencies easier.testImplementation “org.mockito:mockito-core:$MOCKITO_VERSION”Make sure to sync the project after adding the dependency. Android Studio should have created the folder structure for unit tests by default. If not, make sure the following directory structure exists:/app/src/test/java/com/maskaravivek/testingExamplesCreating Your First Unit TestSuppose you want to test the displayUserName function in the UserService. For the sake of simplicity, the function simply formats the input and returns it back. In a real-world application, it could make a network call to fetch the user profile and return the user’s name.@Singletonclass UserService @Injectconstructor(private var context: Context) { var button: Button? = null var userNameField: EditText? = null var displayUserName: TextView? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) AndroidInjection.inject(this) setContentView(R.layout.activity_main) initViews() } Related postsInclusive Components: Book Reviews And Accessibility Resources13th December 2019Should Your Portfolio Site Be A PWA?12th December 2019Building A CSS Layout: Live Stream With Rachel Andrew10th December 2019Struggling To Get A Handle On Traffic Surges10th December 2019How To Design Profitable Sales Funnels On Mobile6th December 2019How To Build A Real-Time Multiplayer Virtual Reality Game (Part 2)5th December 2019 @Module private inner class MockApplicationModule internal constructor(application: Application) : AppModule(application) { override fun provideUserService(context: Context): UserService { val mock = Mockito.mock(UserService::class.java) `when`(mock!!.displayUserName(“Test”)).thenReturn(“Hello Test!”) return mock } }}As you can see in the example above, we’ve used Mockito to mock UserService and assume the results. We still need a new runner that will point to the new application class with the overwritten data.class MockTestRunner : AndroidJUnitRunner() { How To Improve Test Coverage For Your Android App Using Mockito And Espresso How To Improve Test Coverage For Your Android App Using Mockito And Espresso Vivek Maskara 2018-07-25T14:00:04+02:00 2018-07-25T12:06:31+00:00In app development, a variety of use cases and interactions come up as one iterates the code. The app might need to fetch data from a server, interact with the device’s sensors, access local storage or render complex user interfaces.The important thing to consider while writing tests is the units of responsibility that emerge as you design the new feature. The unit test should cover all possible interactions with the unit, including standard interactions and exceptional scenarios.In this article, we will cover the fundamentals of testing and frameworks such as Mockito and Espresso, which developers can use to write unit tests. I will also briefly discuss how to write testable code. I’ll also explain how to get started with local and instrumented tests in Android.Recommended reading: How To Set Up An Automated Testing System Using Android Phones (A Case Study)Fundamentals Of TestingA typical unit test contains three phases.First, the unit test initializes a small piece of an application it wants to test.Then, it applies some stimulus to the system under test, usually by calling a method on it.Finally, it observes the resulting behavior.If the observed behavior is consistent with the expectations, the unit test passes; otherwise, it fails, indicating that there is a problem somewhere in the system under test. These three unit test phases are also known as arrange, act and assert, or simply AAA. The app should ideally include three categories of tests: small, medium and large.Small tests comprise unit tests that mock every major component and run quickly in isolation.Medium tests are integration tests that integrate several components and run on emulators or real devices.Large tests are integration and UI tests that run by completing a UI workflow and ensure that the key end-user tasks work as expected.Note: An instrumentation test is a type of integration test. These are tests that run on an Android device or emulator. These tests have access to instrumentation information, such as the context of the app under test. Use this approach to run unit tests that have Android dependencies that mock objects cannot easily satisfy.Nope, we can’t do any magic tricks, but we have articles, books and webinars featuring techniques we all can use to improve our work. Smashing Members get a seasoned selection of magic front-end tricks — e.g. live designing sessions and perf audits, too. Just sayin’! 😉 Explore Smashing Wizardry →Writing small tests allows you to address failures quickly, but it’s difficult to gain confidence that a passing test will allow your app to work. It’s important to have tests from all categories in the app, although the proportion of each category can vary from app to app. A good unit test should be easy to write, readable, reliable and fast.Here’s a brief introduction to Mockito and Espresso, which make testing Android apps easier.MockitoThere are various mocking frameworks, but the most popular of them all is Mockito:Mockito is a mocking framework that tastes really good. It lets you write beautiful tests with a clean & simple API. Mockito doesn’t give you hangover because the tests are very readable and they produce clean verification errors.Its fluent API separates pre-test preparation from post-test validation. Should the test fail, Mockito makes it clear to see where our expectations differ from reality! The library has everything you need to write complete tests.EspressoEspresso helps you write concise, beautiful and reliable Android UI tests.The code snippet below shows an example of an Espresso test. We will take up the same example later in this tutorial when we talk in detail about instrumentation tests.@Testpublic void setUserName() { onView(withId(R.id.name_field)).perform(typeText(“Vivek Maskara”)); onView(withId(R.id.set_user_name)).perform(click()); onView(withText(“Hello Vivek Maskara!”)).check(matches(isDisplayed()));}Espresso tests state expectations, interactions and assertions clearly, without the distraction of boilerplate content, custom infrastructure or messy implementation details getting in the way. Whenever your test invokes onView(), Espresso waits to perform the corresponding UI action or assertion until the synchronization conditions are met, meaning:the message queue is empty,no instances of AsyncTask are currently executing a task,the idling resources are idle.These checks ensure that the test results are reliable.Writing Testable CodeUnit testing Android apps is difficult and sometimes impossible. A good design, and only a good design, can make unit testing easier. Here are some of the concepts that are important for writing testable code.Avoid Mixing Object Graph Construction With Application LogicIn a test, you want to instantiate the class under test and apply some stimulus to the class and assert that the expected behavior was observed. Make sure that the class under test doesn’t instantiate other objects and that those objects do not instantiate more objects and so on. In order to have a testable code base, your application should have two kinds of classes:The factories, which are full of the “new” operators and which are responsible for building the object graph of your application;The application logic classes, which are devoid of the “new” operator and which are responsible for doing the work.Constructors Should Not Do Any WorkThe most common operation you will do in tests is the instantiation of object graphs. So, make it easy on yourself, and make the constructors do no work other than assigning all of the dependencies into the fields. Doing work in the constructor not only will affect the direct tests of the class, but will also affect related tests that try to instantiate your class indirectly.Avoid Static Methods Wherever PossibleThe key to testing is the presence of places where you can divert the normal execution flow. Seams are needed so that you can isolate the unit of test. If you build an application with nothing but static methods, you will have a procedural application. How much a static method will hurt from a testing point of view depends on where it is in your application call graph. A leaf method such as Math.abs() is not a problem because the execution call graph ends there. But if you pick a method in a core of your application logic, then everything behind the method will become hard to test, because there is no way to insert test doublesAvoid Mixing Of ConcernsA class should be responsible for dealing with just one entity. Inside a class, a method should be responsible for doing just one thing. For example, BusinessService should be responsible just for talking to a Business and not BusinessReceipts. Moreover, a method in BusinessService could be getBusinessProfile, but a method such as createAndGetBusinessProfile would not be ideal for testing. SOLID design principles must be followed for good design:S: single-responsibility principle;O: open-closed principle;L: Liskov substitution principle;I: interface segregation principle;D: dependency inversion principle.In the next few sections, we will be using examples from a really simple application that I built for this tutorial. The app has an EditText that takes a user name as input and displays the name in a TextView upon the click of a button. Feel free to take the complete source code for the project from GitHub. Here’s a screenshot of the app: override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) AndroidInjection.inject(this) setContentView(R.layout.activity_main) initViews() } @Mock internal var context: Context? = null @InjectMocks internal var userService: UserService? = null @Before fun setup() { MockitoAnnotations.initMocks(this) }}Now you are done setting up your test class. Let’s add a test to this class that verifies the functionality of the displayUserName function. Here’s what the test looks like:@Testfun displayUserName() { doReturn(“Hello %s!”).`when`(context)!!.getString(any(Int::class.java)) val displayUserName = userService!!.displayUserName(“Test”) assertEquals(displayUserName, “Hello Test!”)}The test uses a doReturn().when() statement to provide a response when a context.getString() is invoked. For any input integer, it will return the same result, “Hello %s!”. We could have been more specific by making it return this response only for a particular string resource ID, but for the sake of simplicity, we are returning the same response to any input.Finally, here’s what the test class looks like:class UserServiceTest { @Mock internal var context: Context? = null @InjectMocks internal var userService: UserService? = null @Before fun setup() { MockitoAnnotations.initMocks(this) } this.button!!.setOnClickListener({ displayUserName!!.text = “Hello ${userNameField!!.text}!” }) }}To create a test for the MainActivity, we will start by creating a MainActivityTest class under the androidTest directory. Add the AndroidJUnit4 annotation to the class to indicate that the tests in this class will use the default Android test runner class.@RunWith(AndroidJUnit4::class)class MainActivityTest {}Next, add an ActivityTestRule to the class. This rule provides functional testing of a single activity. For the duration of the test, you will be able to manipulate your activity directly using the reference obtained from getActivity().@Rule @JvmField var activityActivityTestRule = ActivityTestRule(MainActivity::class.java)Now that you are done setting up the test class, let’s add a test that verifies that the user name is displayed by clicking the “Set User Name” button.@Testfun setUserName() { onView(withId(R.id.name_field)).perform(typeText(“Vivek Maskara”)) onView(withId(R.id.set_user_name)).perform(click()) onView(withText(“Hello Vivek Maskara!”)).check(matches(isDisplayed()))}The test above is quite simple to follow. It first simulates some text being typed in the EditText, performs the click action on the button, and then checks whether the correct text is displayed in the TextView.The final test class looks like this:@RunWith(AndroidJUnit4::class)class MainActivityTest { @Inject lateinit var userService: UserService @Test fun setUserName() { onView(withId(R.id.name_field)).perform(typeText(“Test”)) onView(withId(R.id.set_user_name)).perform(click()) onView(withText(“Hello Test!”)).check(matches(isDisplayed())) }}The test will run successfully when you click on the green play button in the IDE. fun displayUserName(name: String): String { val userNameFormat = context.getString(R.string.display_user_name) return String.format(Locale.ENGLISH, userNameFormat, name) }}We will start by creating a UserServiceTest class in our test directory. The UserService class uses Context, which needs to be mocked for the purpose of testing. Mockito provides a @Mock notation for mocking objects, which can be used as follows:@Mock internal var context: Context? = nullSimilarly, you’ll need to mock all dependencies required to construct the instance of the UserService class. Before your test, you’ll need to initialize these mocks and inject them into the UserService class.@InjectMock creates an instance of the class and injects the mocks that are marked with the annotations @Mock into it.MockitoAnnotations.initMocks(this); initializes those fields annotated with Mockito annotations.Here’s how it can be done:class UserServiceTest { open fun initAppComponent(): AppComponent { return DaggerAppComponent .builder() .appModule(AppModule(this)) .build() } @Provides @Singleton internal open fun provideUserService(context: Context): UserService { return UserService(context) }}The AppComponent class lets you build the object graph for the application.@Singleton@Component(modules = [(AndroidSupportInjectionModule::class), (AppModule::class), (ActivityBuilder::class)])interface AppComponent { Large previewIntrumentation Testing Using Dagger, Mockito, And EspressoEspresso is one of the most popular UI testing frameworks, with good documentation and community support. Mockito ensures that objects perform the actions that are expected of them. Mockito also works well with dependency-injection libraries such as Dagger. Mocking the dependencies allows us to test a scenario in isolation.Until now, our MainActivity hasn’t used any dependency injection, and, as a result, we were able to write our UI test very easily. To make things a bit more interesting, let’s inject UserService in the MainActivity and use it to get the text to be displayed.class MainActivity : AppCompatActivity() { HomeWeb DesignHow To Improve Test Coverage For Your Android App Using Mockito And Espressocenter_img private fun initViews() { button = this.findViewById(R.id.set_user_name) userNameField = this.findViewById(R.id.name_field) displayUserName = this.findViewById(R.id.display_user_name) @Test fun setUserName() { onView(withId(R.id.name_field)).perform(typeText(“Vivek Maskara”)) onView(withId(R.id.set_user_name)).perform(click()) onView(withText(“Hello Vivek Maskara!”)).check(matches(isDisplayed())) }}Running Your Instrumentation TestsJust like for unit tests, click on the green play button in the IDE to run the test. override fun activityInjector(): DispatchingAndroidInjector? { return dispatchingActivityInjector }}Setting Up Dagger In The Test ApplicationIn order to mock responses from the server, we need to create a new Application class that extends the class above.class TestExamplesApplication : ExamplesApplication() { fun inject(application: ExamplesApplication)}Create a method that returns the already built component, and then inject this component into onCreate().open class ExamplesApplication : Application(), HasActivityInjector { @Inject lateinit var dispatchingActivityInjector: DispatchingAndroidInjector @Throws(InstantiationException::class, IllegalAccessException::class, ClassNotFoundException::class) override fun newApplication(cl: ClassLoader, className: String, context: Context): Application { return super.newApplication(cl, TestExamplesApplication::class.java.name, context) }}Next, you need to update the build.gradle file to use the MockTestRunner.android { … override fun onCreate() { super.onCreate() initAppComponent().inject(this) } private fun initViews() { button = this.findViewById(R.id.set_user_name) userNameField = this.findViewById(R.id.name_field) displayUserName = this.findViewById(R.id.display_user_name) @Test fun displayUserName() { doReturn(“Hello %s!”).`when`(context)!!.getString(any(Int::class.java)) val displayUserName = userService!!.displayUserName(“Test”) assertEquals(displayUserName, “Hello Test!”) }}Running Your Unit TestsIn order to run the unit tests, you need to make sure that Gradle is synchronized. In order to run a test, click on the green play icon in the IDE. override fun initAppComponent(): AppComponent { return DaggerAppComponent.builder() .appModule(MockApplicationModule(this)) .build() } var button: Button? = null var userNameField: EditText? = null var displayUserName: TextView? = null How To Improve Test Coverage For Your Android App Using Mockito And EspressoYou are here: @Rule @JvmField var activityActivityTestRule = ActivityTestRule(MainActivity::class.java) defaultConfig { … testInstrumentationRunner “.MockTestRunner” }}Running The TestAll tests with the new TestExamplesApplication and MockTestRunner should be added at androidTest package. This implementation makes the tests fully independent from the server and gives us the ability to manipulate responses.With the setup above in place, our test class won’t change at all. When the test is run, the app will use TestExamplesApplication instead of ExamplesApplication, and, thus, a mocked instance of UserService will be used.@RunWith(AndroidJUnit4::class)class MainActivityTest { @Rule @JvmField var activityActivityTestRule = ActivityTestRule(MainActivity::class.java) this.button!!.setOnClickListener({ displayUserName!!.text = userService.displayUserName(userNameField!!.text.toString()) }) }}With Dagger in the picture, we will have to set up a few things before we write instrumentation tests.Imagine that the displayUserName function internally uses some API to fetch the details of the user. There should not be a situation in which a test does not pass due to a server fault. To avoid such a situation, we can use the dependency-injection framework Dagger and, for networking, Retrofit.Setting Up Dagger In The ApplicationWe will quickly set up the basic modules and components required for Dagger. If you are notfamiliar with Dagger, check out Google’s documentation on it. We will start adding dependencies for using Dagger in the build.gradle file.implementation “com.google.dagger:dagger-android:$DAGGER_VERSION”implementation “com.google.dagger:dagger-android-support:$DAGGER_VERSION”implementation “com.google.dagger:dagger:$DAGGER_VERSION”kapt “com.google.dagger:dagger-compiler:$DAGGER_VERSION”kapt “com.google.dagger:dagger-android-processor:$DAGGER_VERSION”Create a component in the Application class, and add the necessary modules that will be used in our project. We need to inject dependencies in the MainActivity of our app. We will add a @Module for injecting in the activity.@Moduleabstract class ActivityBuilder { @ContributesAndroidInjector internal abstract fun bindMainActivity(): MainActivity}The AppModule class will provide the various dependencies required by the application. For our example, it will just provide an instance of Context and UserService.@Moduleopen class AppModule(val application: Application) { @Provides @Singleton internal open fun provideContext(): Context { return application } Large previewThat’s it! You have successfully set up Dagger and run tests using Espresso and Mockito.ConclusionWe’ve highlighted that the most important aspect of improving code coverage is to write testable code. Frameworks such as Espresso and Mockito provide easy-to-use APIs that make writing tests for various scenarios easier. Tests should be run in isolation, and mocking the dependencies gives us an opportunity to ensure that objects perform the actions that are expected of them.A variety of Android testing tools are available, and, as the ecosystem matures, the process of setting up a testable environment and writing tests will become easier.Writing unit tests requires some discipline, concentration and extra effort. By creating and running unit tests against your code, you can easily verify that the logic of individual units is correct. Running unit tests after every build helps you to quickly catch and fix software regressions introduced by code changes to your app. Google’s testing blog discusses the advantages of unit testing.The complete source code for the examples used in this article is available on GitHub. Feel free to take a look at it. (da, lf, ra, al, il)From our sponsors: How To Improve Test Coverage For Your Android App Using Mockito And Espresso Posted on 25th July 2018Web Design FacebookshareTwittertweetGoogle+share making sure that Gradle is synchronizedWhen the unit tests are run, successfully or otherwise, you should see this in the “Run” menu at the bottom of the screen:Large previewYou are done with your first unit test!Writing Instrumentation TestsInstrumentation tests are most suited for checking values of UI components when an activity is run. For instance, in the example above, we want to make sure that the TextView shows the correct user name after the Button is clicked. They run on physical devices and emulators and can take advantage of the Android framework APIs and supporting APIs, such as the Android Testing Support Library.We’ll use Espresso to take actions on the main thread, such as button clicks and text changes.Setting Up The Development EnvironmentAdd a dependency on Espresso:androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.1’Instrumentation tests are created in an androidTest folder./app/src/androidTest/java/com/maskaravivek/testingExamplesIf you want to test a simple activity, create your test class in the same package as your activity.Creating Your First Instrumentation TestLet’s start by creating a simple activity that takes a name as input and, on the click of a button, displays the user name. The code for the activity above is quite simple:class MainActivity : AppCompatActivity() {last_img read more

Alabama Tax Amnesty Program Enacted

first_imgThe Alabama Tax Delinquency Amnesty Act of 2018 has been enacted. The amnesty program will be held from  July 1, 2018, to September 30, 2018.Eligibility for Alabama Tax AmnestyThe program applies to all taxes administered by the Department of Revenue except for motor fuel, motor vehicle, and property taxes. The taxes eligible for amnesty include:taxes due prior to January 1, 2017, andtaxes for taxable periods that began before January 1, 2017.Taxpayers must waive any right to protest or initiate an administrative or judicial proceeding to participate in the program. The agreement only applies to the specific tax and the tax period for which amnesty is granted. Amnesty applications will be submitted electronically.Waiver of interest and penaltiesThe program waives all of the interest and penalties associated with the tax periods for which amnesty is granted. However, penalties may be imposed for various reasons, including failing to comply with the amnesty provisions, providing false or fraudulent information, and/or cost of collection penalties.Look-back periodsA limited look-back period of the last three full tax years, or 36 months, applies separately to each tax type. If the taxpayer has collected any tax without remitting the tax to the department, the look-back period will be extended to include all periods, back to the point of collection.Amnesty requirementsAn eligible taxpayer who is granted amnesty must comply with many requirements.Past Tax ReturnsTaxpayers must submit to the department, by November 15, 2018, all applicable returns, supporting documentation, and the full payment of the tax. No payment plans will be entered into for taxes that are approved for amnesty. An amnesty payment or return submitted in a properly addressed envelope with sufficient postage delivered by the U.S. Postal Service is deemed paid or received on the date it is postmarked. An amnesty payment or return delivered by courier or taxpayer is deemed paid or received on the date it is delivered to the department’s headquarters or a regional office.Current Year ReturnIn addition, taxpayers have to include the current year return with the amnesty returns filed for the eligible tax type. Penalties for failure to timely file a return and failure to timely pay will be waived. However, waiver of interest does not apply to current year returns.Ineligible taxpayersTax amnesty may not be granted to a taxpayer under several circumstances.The taxpayer is a party to a criminal investigation or criminal litigation pending as of March 6, 2018 for nonpayment, delinquency, or fraud in relation to any state tax administered by the department.The taxpayer has delivered or disclosed a false or fraudulent application, document, return, or other statement to the department in connection with an amnesty application.The taxpayer has been issued a final assessment in which the appeal period has ended.The taxpayer has entered into a voluntary disclosure agreement with the department before December 31, 2017.The taxpayer has been granted amnesty for the tax type as part of the Alabama Tax Delinquency Amnesty Act of 2016.Act 2018-153 (H.B. 137), Laws 2018, effective March 6, 2018Login to read more tax news on CCH® AnswerConnect or CCH® Intelliconnect®.Not a subscriber? Sign up for a free trial or contact us for a representative.last_img read more

10 months agoMan City management make January market decision

first_imgMan City management make January market decisionby Paul Vegas10 months agoSend to a friendShare the loveManchester City are willing to go through January without adding to Pep Guardiola’s squad.Last season’s champions City have fallen behind the Reds in this season’s title race after losing two games on the bounce against Crystal Palace and Leicester City respectively.But The Times says City have no plans to enter the transfer market when it opens next week.Both Guardiola and the Citizens board believe they can catch Liverpool and retain their Premier League crown. TagsTransfersAbout the authorPaul VegasShare the loveHave your saylast_img read more

Man charged in daughters death in hospital with selfinflicted gunshot wound police

first_imgPolice say a man charged with first-degree murder in the death of his daughter is in hospital with a self-inflicted gunshot wound.Roopesh Rajkumar, 41, was charged in 11-year-old Riya Rajkumar’s death after the girl’s body was found in his Brampton, Ont., home shortly after an Amber Alert was issued late Thursday night.Peel regional police say they were called by Riya’s mother after the child’s father failed to return her home from her birthday celebrations.Police say Roopesh was arrested by provincial police shortly after Riya’s body was found and was taken to hospital for injuries that were kept secret for several days.They say the province’s police watchdog was notified of his injury, but decided to not investigate the circumstances surrounding it.Police say Rajkumar is in custody, and will have a court appearance once his doctors say he is well enough.The Canadian Presslast_img read more

30 NFL teams survey Buckeye prospects at Pro Day

Ohio State football players showed their talents for 30 different NFL teams at the Buckeyes’ Pro Day in the Woody Hayes Athletic Center Friday. Thirteen players, including running back Daniel “Boom” Herron, wide receiver DeVier Posey, offensive tackles Mike Adams and J.B. Shugarts, linebacker Andrew Sweat and center Mike Brewster, attended the workout. Scouts from every NFL team except the Chicago Bears and New York Jets came to take in the action and evaluate the NFL hopefuls. Herron compared the day to a job interview. “(There were) a lot of great coaches out here,” Herron said. “You just want to put on the best show, be at your best.” The Buckeyes’ Pro Day, which was led by OSU football strength and conditioning coach Mickey Marotti, schedule featured events such as the 40-yard dash, 20-yard shuttle, three cone drill, broad jump and individual position drills. The 40-yard dash, which is considered by many as one of the most important measurable heading into the NFL Draft in April, saw only 10 Buckeyes and three non-OSU participants participate in the drill as Posey, Adams and Brewster opted to not test their 40-times. Posey said the day’s events were the best part of the drafting process. “This is the best part, man. Just football,” Posey said. “Running routes, catching balls, I feel like I do that the best. I just wanted to come out and make sure I catch everything today.” Shugarts said he met with several teams, including the Kansas City Chiefs. “I was doing a lot of board work with the Chiefs,” Shugarts said. “I just got done with that … Just going over pass protections, they asked us our favorite run plays.” While the purpose of the day was for Buckeye football players to prove to NFL scouts they have the ability to play at the next level, players’ family, friends and a number of former OSU players showed up to watch the action for themselves. Notably, former Buckeye football players Beanie Wells, Jim Cordle, Doug Worthington, Bobby Carpenter, Joey Galloway, LeCharles Bentley, Chris Spielman, Andy Katzenmoyer and Dick LeBeau attended. Additionally, current OSU football players such as Braxton Miller, Etienne Sabino, Travis Howard and Bradley Roby also came to support their former teammates. Other players who took part in the day’s trials were Dionte Allen, Nate Ebner, Donnie Evege, Aaron Gant and Grant Schwartz. In some ways, Friday’s combine was one of the last chances for OSU players to improve their NFL Draft status in the eyes of teams around the league. Officially, the draft opens on April 26. Andrew Hollern contributed to this story. read more

How the Ohio State baseball team passes the time during rain delays

Rain delays are a big part of baseball, and the Ohio State baseball team was reminded of that this past weekend. During rain-outs, the players have to keep themselves entertained, and the Buckeyes have a few preferred pastimes they use while waiting to participate in America’s pastime. A game can be delayed when rain causes low visibility for players, the field isn’t playable due to pooling or standing water or if there is lightning in the area, according to the Major League Baseball rule book. The umpires at the games make rulings about rain delays. Delayed games might be resumed when the weather improves to the umpires’ liking, or the field is cleared of water, but are canceled and can be made up in a doubleheader if the problem persists. The OSU baseball team had two games postponed due to rain. The most recent weather-related interruption in the Buckeyes’ schedule occurred Saturday when OSU’s afternoon game against Nebraksa was rained out and rescheduled for Sunday as part of a doubleheader. OSU lost both games, 5-4, and 17-9, respectively, and lost the series, 2-1. The Buckeyes also had seven games rained-out and cancelled last season. Buckeye players said no one has done anything comparable to the viral videos of minor-leaguers jousting or holding a dance competition, but they like to have fun during weather delays. “We haven’t had any jousting, but we had our manager slide across the turf when it was raining,” said senior outfielder Dave Corna. “But for the most part, we’re just fooling around and staying loose.” Senior pitcher Andrew Armstrong said the Buckeyes haven’t had a chance to bust out anything too crazy since there’s only been one rain delay. Armstrong also said as a team, they like to stay relaxed during delays before and during games. “It all really depends on what you feel like doing,” Armstrong said. “Some guys like to have fun and do stuff. We’ll go and play two-ball, a practice game or we’ll watch TV. It depends on the mood of the game. Like, if we’re losing probably not a lot, but if it’s before the game we’ll just have fun.” Players said they like to stay relaxed during the delays in the middle of games, but coach Greg Beals said the players tend to keep working as well. “You try to keep it loose,” Beals said. “Some guys will go in (to the team clubhouse) and play cards or play XBOX, and some guys will even hit in the batting cages. Other guys will just sit in the dugout and play the name game. A bunch of different stuff goes on.” Beals said his team is full of guys with lots of personality, but the fun will stay in-house when the tarp is rolled out onto the field because of rain. “We’ve got some good characters in our club, but we’re not the type to go out on stage and do it,” Beals said. “We’ll keep it in the clubhouse.” read more

Kevin De Bruyne returns to training at Man City

first_imgManchester City have received a welcome boost by the return of Kevin De Bruyne after a seven-week absenceThe Belgian playmaker sustained a knee injury in a training session just days after City’s opening day 2-0 win away to Arsenal in August, which ruled him out for the next three months.But, following manager Pep Guardiola’s comments that De Bruyne could return to training this week, City have now confirmed the news.The 27-year-old joined the rest of the first-team for a morning training session as City prepare for their Champions League trip to Hoffenheim on Tuesday.No timetable for De Bruyne’s return to competitive action has been released yet by City, although it’s understood that the player himself is planning on coming back for the Manchester derby on November 11.Premier LeaguePremier League Betting: Match-day 5 Stuart Heath – September 14, 2019 Going into the Premier League’s match-day five with a gap already beginning to form at the top of the league. We will take a…Despite a foot injury, Sergio Aguero was also in attendance during the training session as City hope to bounce back from their Group F opening defeat to Lyon last month.Back in training! 💪🏼 pic.twitter.com/ABeELZU7MA— Kevin De Bruyne (@DeBruyneKev) October 1, 2018last_img read more