testing

R: ggplot2 - Kruskal-Wallis test per facet

我们两清 提交于 2021-01-27 19:12:16
问题 I have boxplots in multiple facets and I would like to perform a Kruskal-Wallis test on each facet, and place the result on top-left of each respective facet. To exemplify this, I am using the iris dataset, to which I added an additional variable named "treatment". MWE: library(reshape2) library(ggplot2) data(iris) iris$treatment <- rep(c("A","B"), length(iris$Species)/2) mydf <- melt(iris, measure.vars=names(iris)[1:4]) mydf$treatment <- as.factor(mydf$treatment) mydf$variable <- factor(mydf

How to mock/spy useState hook in jest?

亡梦爱人 提交于 2021-01-27 18:41:12
问题 I am trying to spy on useState React hook but i always get the test failed This is my React component: const Counter= () => { const[counter, setCounter] = useState(0); const handleClick=() => { setCounter(counter + 1); } return ( <div> <h2>{counter}</h2> <button onClick={handleClick} id="button">increment</button> </div> ) } counter.test.js : it('increment counter correctlry', () => { let wrapper = shallow(<Counter/>); const setState = jest.fn(); const useStateSpy = jest.spyOn(React,

One Test-Class per method?

痴心易碎 提交于 2021-01-27 18:32:01
问题 since today I have used the pattern to create one test class per class. For example the class "Foo" with the methods "DoSomething" and "DoNothing" had one test class called "FooTests". Now I have heard about creating one test class for every method. For the previous example this would mean I create two new classes called "DoSomethingTests" and "DoNothingTests" instead of the class "FooTests". Is this a commonly used pattern and should I switch to this one, or is this furthermore an anti

Gradle 'error: package com.google.common.collect does not exist'

泪湿孤枕 提交于 2021-01-27 14:54:03
问题 I am following a little test script and providing it with the first piece of code to make it green. The code is java and the testing is gradle with java. Java is version "1.8.0_60" on Mac OSX "El Capitan". gradle is version 2.8. After using gradle build , here is the error shown: $ gradle build :compileJava /Users/rsalazar/exercism/java/etl/src/main/java/Etl.java:1: error: package com.google.common.collect does not exist import com.google.common.collect.ImmutableMap; ^ /Users/rsalazar

Reading Excel file with Scala

早过忘川 提交于 2021-01-27 14:50:36
问题 I am writing a quick test that registers a user with the data from a spreadsheet. The idea is Go to the website > click register > Read excel rows A1 and B1 for email and password > use this data on registration site> finish the registration > log out > Register a new user with information from rows A2 and B2 > continue until rows in the spreadsheet are empty. I have managed to automate the registration process with random user information and now I just need to make it do the same with the

Gradle 'error: package com.google.common.collect does not exist'

强颜欢笑 提交于 2021-01-27 14:44:16
问题 I am following a little test script and providing it with the first piece of code to make it green. The code is java and the testing is gradle with java. Java is version "1.8.0_60" on Mac OSX "El Capitan". gradle is version 2.8. After using gradle build , here is the error shown: $ gradle build :compileJava /Users/rsalazar/exercism/java/etl/src/main/java/Etl.java:1: error: package com.google.common.collect does not exist import com.google.common.collect.ImmutableMap; ^ /Users/rsalazar

How do I mock a third party library inside a Django Rest Framework endpoint while testing?

我怕爱的太早我们不能终老 提交于 2021-01-27 14:31:15
问题 The user creation endpoint in my app creates a firebase user (I have a chat room inside the app, powered by firebase) with the same id as my django user. from django.contrib.auth.models import User from rest_framework import generics from rest_framework import permissions from apps.core.services import firebase_chat class UserCreate(generics.GenericAPIView): permission_classes = [permissions.AllowAny] @transaction.atomic def put(self, request): user = User.objects.create(**request.data)

Extending SuperTest

对着背影说爱祢 提交于 2021-01-27 13:37:31
问题 I like to use SuperTest to work with my auth system like this: const request = require('./valid_access_token')(require('supertest')); request(app) .get('/v1/bots') .valid_token() .expect('Content-Type', /json/) ... valid_token() would insert a valid access-token module.exports = function (Request) { const Token = require('../../../app/v1/models/loader')('token'); const UserFactory = require('../fixtures/user'); Request.prototype.valid_token = function() { return UserFactory.createAsync('user'

go test in complex folder structure

巧了我就是萌 提交于 2021-01-27 13:32:15
问题 I am building a repository of design patterns in golang. To run all tests, I use this bash script. It works. #!/bin/bash go test creational/abstract_factory/*.go go test creational/builder/*.go go test creational/factory/*.go go test creational/pool/*.go go test creational/prototype/*.go go test creational/singleton/*.go It works fine: prompt> ./runtests.sh ok command-line-arguments 0.006s ok command-line-arguments 0.006s ok command-line-arguments 0.006s ok command-line-arguments 0.006s ok

How do I pass variable data between tests

浪子不回头ぞ 提交于 2021-01-27 13:21:31
问题 I am trying to do something similar to this post on TestCafe I am generating a random email in my helper.js file. I would like to use this random email to log in the test.js file. This is how I am creating my email in the helper.js var randomemail = 'test+' + Math.floor(Math.random() * 10000) + '@gmail.com' This is how I want to use it in my test.js file .typeText(page.emailInput, randomemail) I have tried several things without luck. How could I go about using the generated email in my test