投稿時間:2021-10-22 02:25:53 RSSフィード2021-10-22 02:00 分まとめ(31件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT ITmedia 総合記事一覧 [ITmedia News] フルサイズミラーレスの新基準「α7 IV」海外発表 3300万画素 約2500ドルで12月発売 https://www.itmedia.co.jp/news/articles/2110/22/news065.html 発売予定 2021-10-22 01:30:00
js JavaScriptタグが付けられた新着投稿 - Qiita コードインジェクション攻撃 https://qiita.com/bricolageart/items/96adf44a75a0e662ceee 静的コード分析SCAツールの使用によるコードインジェクションの発見と修正ESLintで使用される基本的な形式の静的コード分析SCAlinterは、出発点としては良いのですが、コードスタイルを適用するのに十分なコンテキストを提供するだけで、Nodejssecuritylinterで確認したように、セキュリティの問題に必要な対処が実際にできるほど柔軟ではありません。 2021-10-22 01:05:55
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Hololens2をUSBケーブルでPCに接続しDevicePortalを参照する https://teratail.com/questions/365602?rss=all 2021-10-22 01:39:24
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) phpmyadomin ユーザ権限を設定したroleカラムにデフォルト値しかフォームから入力できない https://teratail.com/questions/365601?rss=all phpmyadominユーザ権限を設定したroleカラムにデフォルト値しかフォームから入力できない【実現したいこと】Laravelの自作システムで権限付加しているテーブルカラムへ、フォームから数字を登録したい閲覧ありがとうございます。 2021-10-22 01:36:47
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Javaのscannerの文字化けへの対処法 https://teratail.com/questions/365600?rss=all Javaのscannerの文字化けへの対処法前提・実現したいことvscodeを使ってJavaの練習をしているのですが、scannerを使用して日本語の入力を受け取ろうとすると文字化けしてしまいます。 2021-10-22 01:27:36
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) GitHubとPythonを同時に学びたい。 https://teratail.com/questions/365599?rss=all GitHubとPythonを同時に学びたい。 2021-10-22 01:01:57
Docker dockerタグが付けられた新着投稿 - Qiita 【構築】Oracle Data Guard (12.2) https://qiita.com/tkmtmkt/items/d875b3f83d2cb52b4256 mkdirpdboptoraclefastrecoveryareaoradatachmodawdboptoraclefastrecoveryareaoradatadockerコンテナ作成※使用環境ではdockercomposeはdockercomposeコマンドで使用する。 2021-10-22 01:26:00
海外TECH MakeUseOf Use Microsoft Word's Quick Parts to Insert Frequently Used Text https://www.makeuseof.com/use-microsoft-word-quick-parts-insert-frequent-text/ Use Microsoft Word x s Quick Parts to Insert Frequently Used TextThe Quick Parts tool makes it easy to store and access content you want to use frequently like addresses signatures and emails Here s how to use it 2021-10-21 16:45:32
海外TECH MakeUseOf How to Enable and Disable Closed Captions on Shudder https://www.makeuseof.com/how-to-enable-closed-captions-on-shudder/ shudder 2021-10-21 16:32:51
海外TECH MakeUseOf 6 Ways to Fix a Laggy Zoom on Windows 10 https://www.makeuseof.com/how-to-fix-laggy-zoom-windows-10/ laggy 2021-10-21 16:32:50
海外TECH DEV Community Google Charts Dashboard: a Tutorial with an Artistic Touch of MoMA 🖼 https://dev.to/cubejs/google-charts-dashboard-a-tutorial-with-an-artistic-touch-of-moma-1jdn Google Charts Dashboard a Tutorial with an Artistic Touch of MoMA In this tutorial we ll learn how to visualize data with Google Charts a free charting service and JavaScript library by Google We ll also use Cube an open source API for building data apps to provide access to the public dataset with The Museum of Modern Art collection data In the end we ll have a dashboard with charts that tell all about MoMA s contemporary artworks Here s how the end result will look like Want to try it Here s the live demo you can use right away  Also the full source code is available on GitHub Now we re all set Please check your ticket and proceed to Floor Charting Gallery What is Google Charts Google Charts is a charting service by Google that provides a rich selection of data visualization types renders charts using HTML and SVG provides cross browser compatibility and cross platform portability meaning that charts look nice both on desktop and mobile Why is it a charting service not a charting library Indeed Google Charts provide a JavaScript library that takes the data and renders charts on the web page However unlike other data visualization tools Google Charts don t render all the charts on the client side Instead for some of the charts they pass the data to Google servers render a chart there and then display the result on the page Such an approach has its pros Rendering code is browser and platform independent which provides increased compatibility and portability If it renders once it will render anytime The size of the JavaScript library is fixed and doesn t depend on the features used And it s actually really tiny ーless than KB gzipped But it also has its cons For some charts data has to be uploaded to Google servers for the chart to be rendered If you deal with sensitive data please check the Google APIs Terms of Service Also make sure to always check the Data Policy sections in the docs In this tutorial we ll be using a public dataset so it s not a big deal Which charts are available Among the usual suspects like line charts bar charts or pie charts you can find a few distinctive ones Calendar charts that you must have seen numerous times at GitHub profiles Gantt charts that you might have wished to never encounter because of their affinity to enterprise software Diff charts that combine a couple of scatter charts pie charts or bar charts into an image that visualizes the difference between two similar datasets Vega charts that provide a way to render charts defined with Vega and Vega Lite visual grammars in Google Charts Enjoying the sight so far Please proceed to Floor Modern Arts What is MoMA The Museum of Modern Art is an art museum in New York USA It was established years ago on November and it s often identified as one of the largest and most influential museums of modern art in the world MoMA s collection includes almost works of architecture and design  drawing  painting  sculpture  photography  prints  illustrated books  film and electronic media On GitHub MoMA publishes and periodically updates a public dataset which contains records representing all of the works that have been accessioned into MoMA s collection and cataloged in our database It includes basic metadata for each work e g title artist date made medium dimensions and date of acquisition This dataset is placed in the public domain using a CC License so we re free to use it in this tutorial and available in CSV and JSON formats I ve imported this dataset to a publicly available Postgres instance that we ll use in a few minutes to explore the data Proceed to Floor Cubism What is Cube We re building a dashboard so it would be very convenient to access the data from the front end via an API Cube comes particularly handy for this purpose Cube is a popular open source product with more than stars on GitHub to date It serves as an API for building data apps You can configure Cube to connect to any database describe your data with a declarative data schema and instantly get an API that you can use in your app Let s spin up an API for the MoMA dataset First please make sure you have Docker installed on your machine It s recommended to run Cube with Docker or use a managed instance in Cube Cloud Second let s create a new folder for your Cube app and navigate to it mkdir google charts momacd google charts momaThird run this snippet to create a new docker compose yml file with the configuration We ll also use environment variables from the  env file to instruct Cube how to connect to Postgres cat gt docker compose yml lt lt EOLversion services cube image cubejs cube latest ports env file env volumes cube confEOLThen run this snippet to create the  env file with Postgres credentials In this tutorial we re using a publicly available Postgres database that I ve already set up Check the docs to learn more about connecting Cube to Postgres or any other database cat gt env lt lt EOLCUBEJS DB TYPE postgresCUBEJS DB HOST demo db examples cube devCUBEJS DB NAME momaCUBEJS DB USER cubeCUBEJS DB PASS CUBEJS API SECRET SECRETCUBEJS DEV MODE trueEOLThat is all we need to let Cube connect to Postgres The last part of configuration is the data schema which declaratively describes the contents of the database Let s put it under the schema folder mkdir schematouch Artworks jsPlease copy and paste this data schema into Artworks js then follow the comments in the file cube Artworks Cube definition It says that the data is kept in the artworks table Learn more in the docs sql SELECT FROM public artworks Quantitative information about the data e g count of rows It makes sense for all rows rather than individual rows measures count type count minAgeAtAcquisition type number sql MIN CUBE ageAtAcquisition avgAgeAtAcquisition type number sql SUM CUBE ageAtAcquisition CUBE count maxAgeAtAcquisition type number sql MAX CUBE ageAtAcquisition Qualitative information about the data e g an artwork s title It makes sense for individual rows of data rather than all rows dimensions title sql CUBE Title type string artist sql CUBE Artist type string classification sql CUBE Classification type string medium sql CUBE Medium type string We can use SQL functions here year sql SUBSTRING CUBE Date FROM type number date sql CUBE Date type number dateAcquired sql CUBE DateAcquired type time yearAcquired sql DATE PART year CUBE DateAcquired type number ageAtAcquisition case when sql CUBE yearAcquired INT CUBE year INT gt label sql CUBE yearAcquired INT CUBE year INT else label type number heightCm sql ROUND CUBE Height cm type number widthCm sql ROUND CUBE Width cm type number dataSource default Whew Now we re finally ready to run Cube docker compose upNow let s review the data in the MoMA dataset Cube provides the Developer Playground a convenient web based tool that helps explore the data at localhost Navigate to the Developer Playground in your browser and explore the UI You can retrieve arbitrary data slice and dice the dataset by selecting dimensions and measures For example you can check how many artworks MoMA has for the artists that have Sarah in their name To do so select the Artworks count measure the Artworks artist dimension and also make sure to add a filter for the Artworks artist dimension that allows only the names containing Sarah Feel free to tinker with other measures and dimensions Once you re done let s get to building the dashboard Proceed to Floor Abstract Art Building a dashboard with Google ChartsNow it s time to develop a front end application telling the story behind the MoMA artworks collection with charts and other types of data visualizations For simplicity let s build it with pure JavaScript and without any frameworks however unofficial packages are available on NPM for React Angular and Vue as well as TypeScript definitions in the DefinitelyTyped repository Basic dashboard First let s create a subfolder for the dashboard under the google charts moma folder mkdir dashboard appcd dashboard appSecond let s start with an HTML file with the following contents You can name it basic html and put in that dashboard app folder We ll go through this file line by line Follow the comments lt html gt lt head gt lt Load Cube API library UMD version for in browser use gt lt script type text javascript src cubejs client core dist cubejs client core umd js gt lt script gt lt Load Google Charts API gt lt script type text javascript src gt lt script gt lt script type text javascript gt Cube API token and host Change to http localhost to use your own Cube See the docs to learn more about authentication const cubeToken eyJhbGciOiJIUzINiIsInRcCIIkpXVCJ eyJpYXQiOjEwMDAwMDAwMDAsImVcCINTAwMDAwMDAwMH OHZOpOBVKr sCwnsbZUFsqIuCseomTPWVMFw const cubeHost Instantiate Cube API client const cubeApi cubejs cubeToken apiUrl cubeHost cubejs api v Load Google Charts API and packages corechart is the main one google charts load current packages corechart table Set a callback to run when the Google Visualization API is loaded google charts setOnLoadCallback drawCharts Function that creates the charts We ll start with just a couple of them function drawCharts drawChartForArtworkArtists drawChartForArtworkYears Function that creates a table chart See the docs to learn more function drawChartForArtworkArtists Cube query that will fetch ーartists names ーcount of artworks for each artist ーbut only for those artworks that are labeled as paintings Learn more about query format in the docs const query dimensions Artworks artist measures Artworks count filters member Artworks classification operator equals values Painting Let s execute the query via the Cube API cubeApi load query then resultSet gt and process the result set First let s turn it into an array of two element arrays with names and counts const rows resultSet tablePivot map function row return row Artworks artist parseInt row Artworks count Second let s convert it into Google Charts data table Note that we re passing an array of column names as the first row const data google visualization arrayToDataTable Artist Paintings rows Third let s specify a few options like pagination const options showRowNumber true page enable pageSize width Eventually let s render the chart It will be inserted in place of an HTML element with a known id const chart new google visualization Table document getElementById chart artists chart draw data options Function that creates a scatter chart See the docs to learn more function drawChartForArtworkYears Cube query that will fetch ーproduction years ーacquisition years ーcount of artworks for each year created year acquired pair ーbut only for those artworks that are labeled as paintings ーand have known production year and acquisition year const query dimensions Artworks year Artworks yearAcquired measures Artworks count filters member Artworks classification operator equals values Painting member Artworks yearAcquired operator set member Artworks year operator set cubeApi load query then resultSet gt const maxCount resultSet tablePivot reduce function max row return max lt row Artworks count row Artworks count max const rows resultSet tablePivot map function row return parseInt row Artworks year parseInt row Artworks yearAcquired point opacity row Artworks count maxCount toFixed Note that the third column of data is special It says we ll be passing styles of the dots on the scatter chart const data google visualization arrayToDataTable Year created Year acquired type string role style rows The chart type is different and the options are different as well const options title Year created vs Year acquired hAxis viewWindowMode maximized title Year created vAxis viewWindowMode maximized title Year acquired pointSize height width legend none new google visualization ScatterChart document getElementById chart years draw data options lt script gt lt title gt Google Charts Dashboard lt title gt lt style gt body padding em dashboard display grid grid template columns fr grid column gap em group display grid grid template columns fr fr grid column gap em lt style gt lt head gt lt body gt lt div class dashboard gt lt Charts within the dashboard gt lt div class group gt lt div id chart artists gt lt div gt lt div id chart years gt lt div gt lt div gt lt div gt lt body gt lt html gt Here s what you should get once you save the contents of this file and open it in the browser It s a table and a fancy diagonal chart ーbecause it s unlikely that MoMA can acquire an artwork before it was created right Less than lines of code allowed us to include all libraries query an API transform the data configure charts and render them side by side on the page Not that bad However I wouldn t call it a full fledged dashboard until it allows interaction with elements and change how the data is represented Let s explore how to work with events and cross link the charts Interactive dashboard Please create another file you can call it index html It will contain more lines of code so we ll have more charts and some bits of code that allow working with events Copy and paste the code from GitHub ーand let s go through the most interesting parts together Now we have many charts and many functions to draw them function drawCharts artistFilters drawChartForArtworkArtists artistFilters drawChartForArtworkMediums artistFilters drawChartForArtworkYears artistFilters drawChartForArtworkWidthsHeights artistFilters drawChartForArtworkAcquisitions artistFilters drawChartForArtworkAcquisitionsIn artistFilters drawChartForArtworkAcquisitionsAge artistFilters One of the charts the table with artists names has got an event listener that is fired every time you select one or many table rows or clear the selection As you can see we somehow build the filter for the data using the buildQueryFilter function and then pass this filter to every other chart google visualization events addListener chart select function const artistsFilter buildQueryFilter resultSet chart Artworks artist drawChartForArtworkMediums artistsFilter drawChartForArtworkYears artistsFilter drawChartForArtworkWidthsHeights artistsFilter drawChartForArtworkAcquisitions artistsFilter drawChartForArtworkAcquisitionsIn artistsFilter drawChartForArtworkAcquisitionsAge artistsFilter Here s how we build the filter We access selected rows via chart getSelection If there are no rows selected the filter will be undefined If there are any we ll find the values of selected cells and use them as values in the Cube query filter function buildQueryFilter resultSet chart member const selectedRowNumbers chart getSelection map function x return x row if selectedRowNumbers length return const values resultSet tablePivot filter function row i return selectedRowNumbers indexOf i map function row return row member return member operator equals values That s all you need to add interactivity to the dashboard See how the charts change upon the selection of one or many artists in the first table It s a kind of art isn t it ‍Actually these charts and this whole tutorial are inspired by the work of others that I d like to mention here A Nerd s Guide To The Paintings At MoMA by FiveThirtyEight MoMA on GitHub by YYYY MM DD and this tweet by Steven Lubar Cleaning Off the PaintThank you for reading and following this tutorial I encourage you to spend some time in the docs and explore what else Google Charts are capable of You ll find even more chart types configuration options and advanced features Also thanks for learning about Cube and building dashboards I hope you enjoyed it Please don t hesitate to like and bookmark this post write a comment and give a star to Cube on GitHub I hope that you ll try Cube and Google Charts in your next production gig or your next pet project Good luck and have fun Now proceed to the exit 2021-10-21 16:52:13
海外TECH DEV Community Thinking outside the box: An online resume with Docz https://dev.to/linksake/thinking-outside-the-box-an-online-resume-with-docz-1ila Thinking outside the box An online resume with DoczOne of the best traits of humankind is its curiosity It is so human that in honor of it we named a Mars rover Curiosity in Talking about curiosity in the developer world open source projects top the list since by nature they invite us to experiment modify and share what else we can do with them This is why I propose to think a little outside the box with Docz a software documentation tool that is completely open source IndexWhat is Docz Creating our Docz projectAdding our informationAdding a custom componentDeploy to GitHub PagesParting note What is Docz Docz is a Gatsby based project that simplifies the process of documenting other projects without worrying about configuration speed and support It provides a library that allows you to write MDX pages instead of HTML or JSX files handles the routing and provides plugins for all the other needs that you may have All of this results on projects anyone can contribute to Is this simplicity and friendliness that makes Docz a great option for more than just docs Creating our Docz project Before we can jump into Docz there are some prerequisites that you will need have in order to create the project NodeJSYarn or npmNow that you have the prerequisites let s start by creating a new React app with create react app CRA Go to your terminal and run npx create react app my resumeIf you don t have CRA installed npm will ask you if it s okay to install create react app type y to continue and let CRA create the new project We are using the command npx instead of npm since we want to execute a package not install it to a project You can read more about it here Now lets move to the directory of our project and install Docz cd my resumeyarn add docz or npm install doczThen let s remove everything that CRA created for us inside the src folder since we don t need it rm src Also it is a good idea to add to the gitignore the docz folder since we only needed for development gitignore Docz generated files docz Let s go and create a file named index mdx and a hello world header in the following way lt src index mdx gt name Hello Worldroute Hello world from Docz And it s time to run our development server to see what we have just created yarn docz dev or npm run docz devIf you get an error ERROR while trying to run the development server just delete your yarn lock or package json lock and the node modules folder and install the dependencies again Et voila We have successfully created our Docz project Now is a good time to commit your files Your time to shine Before we start adding more pages let s create a configuration file named doczrc js on the root of our project This will help us to set some meta tags easily but it manages all the configuration of our project doczrc jsexport default title Luis Angel Ortega description Hello I m Luis Angel and this is my resume made with Docz ignore README md The title key will set the suffix for our title tag and it will change the text on the top left corner of our project since it s an online resume I recommend using your name in this field Then the description key that we added will modify the meta description tag on our webpage to display it when it s looked up or shared online The last key will tell Docz to ignore some files and don t display them on the webpage as is in this case with the README file Now let s add more pages I ll add a contact page with my socials and resume one in the following way lt src contact mdx gt name Contactroute contact Contact me Let s talk You can find me on these platforms ️ Email mailto hey luisangelme LinkedIn GitHub Twitter Website lt src resume mdx gt name Resumeroute resume Resume Work Experience lt details gt lt summary gt Software Developer lt a href growthconstant co target blank gt Growth Constant lt a gt Mar Currently lt summary gt lt div style marginLeft em gt lt li gt Full stack developer Ruby on Rails and copywriter for the first project of the start up lt a href virtualdash co target blank gt Virtual Dash lt a gt lt li gt lt div gt lt details gt lt details gt lt summary gt Backend Developer Intern lt a href facturasamurai com target blank gt Factura Samurai lt a gt Aug Dec lt summary gt lt div style marginLeft em gt lt li gt Implemented the user authentication on the Elixir API lt li gt lt li gt Learn and developed serverless services Cloudflare Workers with TypeScript lt li gt lt div gt lt details gt lt details gt lt summary gt Full Stack Web Developer lt a href biobot farm target blank gt biobot farm lt a gt Aug Jun lt summary gt lt div style marginLeft em gt lt li gt Successfully launched a new service web application that was developed form scratch while learning React lt li gt lt li gt Documented the web application and taught a colleague to mantener said application lt li gt lt li gt Improved speed functionality and readability of a Python API and micro services lt li gt lt div gt lt details gt Education lt details gt lt summary gt Bachelor s Degree in Information Technologies and Telecomunications lt a href ulsachihuahua edu mx site target blank gt Universidad La Salle Chihuahua lt a gt Aug Dic lt summary gt lt div style marginLeft em gt lt li gt Degree on engineering on information and telecommunication with specialization on mobile development lt li gt lt li gt Academic exchange semester at La Salle Ramon Llull University Barcelona Spain from January to June with the Computer Engineering degree lt li gt lt div gt lt details gt Skills lt details gt lt summary gt Languages lt summary gt lt div style marginLeft em gt lt li gt Spanish Native lt li gt lt li gt English Advanced TOFEL ITP lt li gt lt div gt lt details gt lt details gt lt summary gt Tech lt summary gt lt div style marginLeft em gt lt li gt lt b gt Professional level lt b gt lt li gt lt div div style marginLeft em gt lt li gt JavaScript Node React Next lt li gt lt li gt Ruby Rails lt li gt lt li gt SQL MySQL PostgreSQL lt li gt lt li gt Version manager Git lt li gt lt li gt HTML amp CSS lt li gt lt div gt lt div gt lt div style marginLeft em gt lt li gt lt b gt Novice Level lt b gt lt li gt lt div style marginLeft em gt lt li gt Python Bottle lt li gt lt li gt Docker lt li gt lt li gt UNIX lt li gt lt div gt lt div gt lt details gt Achivements Essential part of the winning team of the following hackathons Ideacon Reset Essential part of the nd place team of the Blockchain Mobility Hackathon in Barcelona Spain As you can see using MDX means that we can use Markdown syntax and JSX in the same document giving a lot of flexibility and customization to our Docz projects At the end they will look something like this Spice it Adding a custom component Now let s focus on our index mdx file Let s change it s title to About me lt src index mdx gt name About meroute Hello world from Docz And then create a components folder inside of the src directory There create a welcome jsx component this will replace our Markdown heading to make the root page more interesting src components welcome jsximport React from react const Welcome props gt const style container display flex flexDirection column textContainer textAlign center imgContainer paddingTop em img display flex margin auto maxWidth borderRadius return lt div style style container gt lt div style style textContainer gt lt h gt props title lt h gt lt span gt props children lt span gt lt div gt lt div style style imgContainer gt lt img style style img src props img alt props title gt lt div gt lt div gt export default WelcomeHere I just made a quick component that takes a title some text and displays it all centered and the image as a circle but you can make your creativity go wild on this one Next let s change index mdx to import our component and use it to give a warm welcome to all the visitors on our webpage here is how it looks It s alive Time to deploy ow that we have our Docz project it s time to build it and deploy it to GitHub Pages since we already have the repository there First we need to configure some things go to your doczrc js file and add a dest key with the value “ docs and a base key the name of your repo as it s value doczrc jsexport default title Luis Angel Ortega description Hello I m Luis Angel and this is my resume made with Docz ignore README md dest docs base docz resume The first key is telling Docz to build the project into the docs directory we re doing this since GitHub Pages expects the static files to be on the root or docs directories The base key is changing the base folder to match the name of the repo in order to make the public files and links to work in GitHub Pages Once we have everything correctly configured we need to build the project with the following command yarn docz build or npm run docz buildWhen it is done you will see a docs folder on your project Commit and push everything to your repo After that let s go to the settings tab on your project and in the left menu go to the Pages section Then select your main branch or the branch on which you are working on and select the docs folder And that is it In a few minutes your website should be live on the link that GitHub has given you The future awaits In this article we only scratched the surface of what Docz is capable of so be sure to check their documentation to learn more I encourage you to read about them to make your resume stand out from the crowd and always remember to support the creators of this amazing project and contribute if you can Find the repo of the project here For end result check out GitHub 2021-10-21 16:45:34
海外TECH DEV Community Android — Instrumentation test with hilt https://dev.to/mahendranv/android-instrumentation-test-with-hilt-2ep6 Android ーInstrumentation test with hiltTesting in Android has been a pain from the beginning and there is no standard architecture setup to execute the frictionless test As you know there is no silver bullet for all the snags This piece of article covers how do you fake dependencies to your hilt viewmodel and assert the same from fragment using espresso What do we achieve here Decoupled UI from navigation and real data sourceFeed fake data to our viewmodelA less flaky test since we control the data or Explained in a single pictureThanks Mr Bean Art disaster Contents Testing strategy Dependency overview Test runner setup Shared test fakes Writing integration test Instrumentation or UI tests Faking modules The HiltAndroidTest Wrapup Resources Testing strategy code coverage is a myth and the more you squeeze towards it you end up with flaky tests Provided the content is dynamic and involves latency due to API calls it is simply hard to achieve So to what degree we should write tests credits mediumUnit tests Small amp fast Even with a large number of tests there won t be much impact on execution time Integration tests Covers how a system integrates with others ex How viewmodel works with the data source Cover the touchpoints Runs on JVM reliable UI tests Tests that cover UI interactions In android this means launching an emulator and running tests in it Slow dead slow So write tests to assert fixed UI states Wrapup at the end of the article should give a rough idea of execution time Here we cover how to write the integration and UI tests using hilt Before the actual implementation take a minute to read on test doubles literally a very short article We ll be using Fakes in our tests Keep in mind while coding Hilt resolves a dependency by its type So our code should refer to the Fake able dependency as interface Provide your dependency in module So that the whole module can be faked along with dependencies More on this is covered in faking modules section Dependency overviewTo recap from previous article we have a fragment that requires a Profile POJO object which is provided through a ViewModel DataRepository acts as a source of truth here and returns a profile ProfileViewModel is unaware of the implementation of DataRepository and Hilt resolves it at compile time Adding to the existing implementation we ll bring in our Fake data source FakeDataRepoImpl for tests So the rest of the post is about instructing Hilt to use FakeDataRepoImpl instead of DataRepositoryImpl Test runner setupAdd test dependencies to app level gradle file This brings a HiltTestApplication and annotation processor to the project now As we ve seen in the scope section HiltTestApplication will hold singleton component File app build gradledependencies Hilt testing androidTestImplementation com google dagger hilt android testing kaptAndroidTest com google dagger hilt android compiler Although HiltTestApplication is present in our app it is not used in tests yet This hookup is done by defining a CustomTestRunner It points to the test application when instantiating the application class for instrument tests File app src androidTest java com ex hiltespresso CustomTestRunner ktimport androidx test runner AndroidJUnitRunnerimport dagger hilt android testing HiltTestApplicationclass CustomTestRunner AndroidJUnitRunner override fun newApplication cl ClassLoader className String context Context Application return super newApplication cl HiltTestApplication class java name context And the final step is to declare the test runner in app gradle file File app build gradleandroid defaultConfig testInstrumentationRunner androidx test runner AndroidJUnitRunner testInstrumentationRunner com ex hiltespresso CustomTestRunner Shared test fakesIn android there are Unit and Instrumentation tests Although both identify as tests they cannot share resources between them Here few places where tests will lookup for classes main source set here we place the production code Fakes have no place heretestShared source set This is the recommended way to share resources Create the below directory structure and place the FakeDataRepoImpl there File app src testShared java com ex hiltespresso data FakeDataRepoImpl ktclass FakeDataRepoImpl Inject constructor DataRepository override fun getProfile Profile name Fake Name age The next step is to add this to test and androidTest source sets In app level gradle file include testShared source set to test sources File app build gradleandroid sourceSets test java srcDirs projectDir src testShared androidTest java srcDirs projectDir src testShared Writing integration testIn the integration test we ll verify data source and viewmodel coupling is proper As seen in the testing strategy section tests run faster if the emulator is not involved Here ViewModel can be tested without UI All it needs is the DataRepository In the last section we placed the FakeDataRepoImpl in the shared source set Let s manually inject it and assert the data File app src test java com ex hiltespresso ui profile ProfileViewModelTest kt RunWith JUnit class class ProfileViewModelTest lateinit var SUT ProfileViewModel Before fun init SUT ProfileViewModel FakeDataRepoImpl Test fun Profile fetched from repository assertThat Name consumed from data source SUT getProfile name is Fake Name Why ProfileViewModel is instantiated manually instead of using Hilt This is the piece of HiltViewModelFactory which instantiates ProfileViewModel The SavedStateRegistryOwner defaultArgs are coming from Activity Fragment that is marked with AndroidEntryPoint So instantiating the viewmodel with hilt also brings in the complexity of launching the activity and testing the viewmodel from there This will result in a slower test whereas viewmodel test can run on JVM like we did above public HiltViewModelFactory NonNull SavedStateRegistryOwner owner Nullable Bundle defaultArgs NonNull Set lt String gt hiltViewModelKeys NonNull ViewModelProvider Factory delegateFactory NonNull ViewModelComponentBuilder viewModelComponentBuilder Instrumentation or UI testsInstrumentation UI tests run on emulator For this project we ll assert whether the name in UI matches the one in fake data source In a real world application the data source is dynamic and mostly involves a web service This means UI tests tend to get flaky So the ideal approach is to bring down the UI to have finite states and map it to the ViewModel and fake it Example UI states UI when the network response has failedUI when there are N items in the list vs the empty state Kotlin sealed classes are a good fit to design an FSM The aforementioned use cases are not covered here and won t fall into a straight line to write an article So here is the blueprint on how do we inject our fake for ViewModel … Faking modulesFor instrument tests androidTest hilt is responsible for instantiating the ViewModel So we need someone who speaks Hilt s language Create a fake module that will provide our FakeDataRepoImpl to the viewmodel File app src androidTest java com ex hiltespresso di FakeProfileModule ktimport dagger hilt android components ViewModelComponentimport dagger hilt testing TestInstallIn Hey Hilt Forget about the ProfileModule use me instead TestInstallIn components ViewModelComponent class replaces ProfileModule class Moduleclass FakeProfileModule Provides fun getProfileSource DataRepository FakeDataRepoImpl Notice the TestInstallIn annotation Defining the replaces array will make the original ProfileModule replaced with FakeProfileModule While building the component hilt will replace the original module and thus dependencies and instantiate the ViewModel with the fake repo Our UI will use the viewmodel and tests will assert the same … The HiltAndroidTestThe final piece is to write a test that uses the faked component All it needs is a couple of test rules and annotation from Hilt Rest is generated File app src androidTest java com ex hiltespresso MainActivityHiltTest kt RunWith AndroidJUnit class HiltAndroidTestclass MainActivityHiltTest get Rule order var hiltRule HiltAndroidRule this get Rule order var activityRule ActivityScenarioRule lt MainActivity gt ActivityScenarioRule MainActivity class java Test fun test name matches data source Inject the dependencies to the test if there is any Inject field in the test hiltRule inject Espresso onView ViewMatchers withId R id name label check ViewAssertions matches Matchers allOf ViewMatchers isDisplayed ViewMatchers withText Fake Name The rules are executed first before running the test It ensures the activity has dependencies resolved before test execution HiltAndroidRule order First create components singleton activity fragment viewmodel and obey the replace contract mentioned in previous step ActivityScenarioRule order Launch the activity mentioned before each testThe espresso amp hamcrest matchers are descriptive In the view tree it lookup for a view and assert whether it s visible and carries the text defined in fake data repo WrapupThis article gave a blueprint for organizing the code in order to achieve component links in isolation Apart from the hilt related setup this practice could benefit even the code that was built with manual injection Just follow these key takeaways Always define the data source as interface So that it can be faked mocked for tests Make fragment activity s UI controlled by the viewmodel You don t have to fake the link here A viewmodel should emit finite states to the UI at any point of time This state may be dictated by the data source or a reaction to user input in UI eg enabling a button based on content length …In case you wonder about the execution time here it is ms vs sec… ResourcesGithub projectHilt testingFinite state machineAndroid test pyramidTest doubles 2021-10-21 16:30:32
Apple AppleInsider - Frontpage News Apple Card now offering 6% Daily Cash on Apple Store purchases https://appleinsider.com/articles/21/10/21/apple-card-now-offering-6-daily-cash-on-apple-store-purchases?utm_medium=rss Apple Card now offering Daily Cash on Apple Store purchasesApple appears to be quietly offering daily cash back for Apple Card users who purchase new hardware or accessories from the online Apple Store Credit AppleThe new promotion which has yet to be officially announced was first spotted by Tailosive Tech At least one other user also shared an image of their Apple Store transaction netting in Daily Cash Back Read more 2021-10-21 16:28:51
Apple AppleInsider - Frontpage News Compared: Apple Watch Series 7 versus Apple Watch Series 6 versus Apple Watch SE https://appleinsider.com/articles/21/09/15/compared-apple-watch-se-versus-apple-watch-series-6-versus-apple-watch-series-7?utm_medium=rss Compared Apple Watch Series versus Apple Watch Series versus Apple Watch SEApple has unveiled the Apple Watch Series but are its new features enough to tempt current Apple Watch SE or Apple Watch Series owners Here s what you should know Credit AppleAt its Sept California Streaming event Apple took the wraps off the Apple Watch Series It did not feature the radical redesign that many Apple watchers were expecting And additionally it didn t expand Apple s existing suite of health features Read more 2021-10-21 16:28:17
Apple AppleInsider - Frontpage News Feds probing Apple & big tech companies about digital payment systems https://appleinsider.com/articles/21/10/21/us-consumer-protection-agency-to-probe-apple-other-big-tech-companies?utm_medium=rss Feds probing Apple amp big tech companies about digital payment systemsThe U S Consumer Financial Protection Bureau has launched a probe into the consumer data and financial practices of digital payment systems including Apple Pay Google PayPal and others Credit Consumer Financial Protection BureauFollowing a Wall Street Journal report that the CFPB was to query big tech firms about data use it has now been revealed that the probe is into management of digital payment systems Read more 2021-10-21 16:55:06
海外TECH Engadget Google starts licensing Stadia tech to other companies https://www.engadget.com/google-stadia-tech-licensing-att-batman-arkham-knight-160913912.html?src=rss Google starts licensing Stadia tech to other companiesWhen Google shut down its internal Stadia game development studios earlier this year Stadia general manager Phil Harrison said the company planned to quot work with partners seeking a gaming solution all built on Stadia s advanced technical infrastructure and platform tools quot We re starting to see that strategy in action as Google is now licensing Stadia tech to other companies As first reported by to Google and confirmed by IGN AT amp T is using the tech to offer wireless subscribers the chance to stream nbsp Batman Arkham Knight nbsp which isn t available on Stadia proper for free Customers can play the game for a limited time at up to p through Google Chrome or Microsoft Edge quot This is being powered by the Stadia technology quot an AT amp T spokesperson told IGN quot For this demo AT amp T created a front end experience to enable gamers to play Batman Arkham Knight directly from their own website and the game is playable on virtually any computer or laptop quot Oddly enough subscribers can t take advantage of this offer on a smartphone despite it seeming like a solid opportunity for AT amp T to show off its network capabilities AT amp T even offered six months of Stadia Pro access to G and fiber internet customers this year Harrison said in February that offering game streaming tech to other companies without Stadia branding in this case was quot the best path to building Stadia into a long term sustainable business that helps grow the industry quot Although Google isn t making its own games for Stadia anymore it has continued to add third party games to the store 2021-10-21 16:09:13
海外科学 NYT > Science The Webb Telescope’s Latest Stumbling Block: Its Name https://www.nytimes.com/2021/10/20/science/webb-telescope-astronomy-homophobia.html The Webb Telescope s Latest Stumbling Block Its NameThe long awaited successor to the Hubble Space Telescope is scheduled to launch in December But the NASA official for whom it is named has been accused of homophobia 2021-10-21 16:27:10
金融 RSS FILE - 日本証券業協会 株券等貸借取引状況(週間) https://www.jsda.or.jp/shiryoshitsu/toukei/kabu-taiw/index.html 貸借 2021-10-21 16:41:00
金融 金融庁ホームページ 金融安定理事会による「サイバー事象報告-既存のアプローチとより広い範囲での収斂に向けた今後のステップ」について掲載しました。 https://www.fsa.go.jp/inter/fsf/20211021/20211021.html 金融安定理事会 2021-10-21 17:00:00
ニュース BBC News - Home Covid: UK cases top 50,000 for first time in three months https://www.bbc.co.uk/news/uk-58999796?at_medium=RSS&at_campaign=KARANGA appointments 2021-10-21 16:34:24
ニュース BBC News - Home Logan Mwangi: Mother and 14-year-old charged with murder https://www.bbc.co.uk/news/uk-wales-58994108?at_medium=RSS&at_campaign=KARANGA bridgend 2021-10-21 16:41:37
ニュース BBC News - Home Strictly Come Dancing: Judi Love to miss this week's show with Covid-19 https://www.bbc.co.uk/news/entertainment-arts-59002666?at_medium=RSS&at_campaign=KARANGA spokesperson 2021-10-21 16:49:09
ニュース BBC News - Home Robot artist Ai-Da released by Egyptian border guards https://www.bbc.co.uk/news/world-us-canada-58993682?at_medium=RSS&at_campaign=KARANGA covert 2021-10-21 16:33:14
ニュース BBC News - Home Royal Cornwall Hospitals Trust declares critical incident https://www.bbc.co.uk/news/uk-england-cornwall-58996914?at_medium=RSS&at_campaign=KARANGA demand 2021-10-21 16:02:21
ニュース BBC News - Home Big John, largest known triceratops skeleton, sold at auction https://www.bbc.co.uk/news/world-europe-58998367?at_medium=RSS&at_campaign=KARANGA european 2021-10-21 16:09:17
ニュース BBC News - Home 'I only knew I'd been spiked when I saw the videos' https://www.bbc.co.uk/news/uk-59002030?at_medium=RSS&at_campaign=KARANGA videos 2021-10-21 16:27:06
北海道 北海道新聞 「身内のような存在」と草刈さん 牧阿佐美さん死去でコメント https://www.hokkaido-np.co.jp/article/602868/ 牧阿佐美 2021-10-22 01:17:00
北海道 北海道新聞 大雨続く道内 河川増水注意 手稲山でも130ミリ https://www.hokkaido-np.co.jp/article/602828/ 道内 2021-10-22 01:16:38
北海道 北海道新聞 NY株、反落 https://www.hokkaido-np.co.jp/article/602867/ 工業 2021-10-22 01:04:00
北海道 北海道新聞 前職の顧客情報 転職後不正利用 容疑の会社員逮捕 https://www.hokkaido-np.co.jp/article/602796/ 顧客情報 2021-10-22 01:02:44

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)